C++ in the kernel

Ivan Voras ivoras at freebsd.org
Tue Oct 30 15:26:30 PDT 2007


On 30/10/2007, Poul-Henning Kamp <phk at phk.freebsd.dk> wrote:
> In message <9bbcef730710300648s4a4162a9x25e5a092111eaab9 at mail.gmail.com>, "Ivan
>  Voras" writes:
> >I think the context of my quote was in favour of this, as long as the
> >language remains standard.
>
> But then again, what exactly is "standard" in this context ?
>
> C99 ? or style(9) ?
>
> We already use a C-diallect, all I'm proposing is giving it more
> theeth so it can help us.

Maybe I can better explain my thoughts and what I mean by "ugly" by
giving an example. This:

SLIST_FOREACH(a,b,c) {
}

is ugly (one of the reasons is that you need to pass the linkage field
name all the time). This:

for x in list {
}

is not. (Yes, the last one looks like a bastard offspring of C and
Python, but it's a coincidence). Tree macros are worse, among other
things for the fact that you constantly need to pass the type name as
an argument. I'm not trying to insult the authors and users of these
macros - they are both convenient and powerful, but you can only go so
far with macros and preprocessor magic before the whole things starts
to sprout mental spikes.

I.e. I'd like something like that to be done right - if a different
language is really needed, than accept a different language (not
butcher C into obedience) as long as it's well defined and used by
more than a dozen people on the Earth.

Re: C++: This:

for (vector<int>::iterator it = v.begin(); it != v.end(); ++it)

still looks pretty ugly but at least it's known to almost any CS/IT
undergrad out there.

My personal choice of a "C++ done right" language is D, it has this variant:

foreach(i, a; args)
    writefln("args[%d] = '%s'", i, a);


More information about the freebsd-arch mailing list