* "Steven T. Hatton said:
I don't know what formal language principle underlies the mechanism. That's
why I'm sitting here with the Standard and a highlighter. Yes, it's in
hardcopy printed using psutils. I'm not using the highlighter on the
electronic version in PDF!
Again I'm not quite sure what you mean. But possibility 1: what you mean by
formal language mechanism is the C++ definition of initializer list. You'll
find that in section §12.6.2 of the Holy Standard. With the colon it's
called a ctor-initializer, and sans the colon it's a mem-initializer-list.
Possibility 2: what you mean by formal language mechanism is a language-
independent thing that §12.6.2 is the C++ language implementation of. Sorry,
can't help you there. Except that it's possible to find formal definitions
of just about anything just by looking and searching hard enough; and if one
does not exist it can always be produced.
Possibility 3: what you mean by formal language mechanism is what purpose
does it serve, when e.g. Java seems to do well without it? Well, one thing
that is different between Java and C++ is that a Java object of a type with
constructor can only be referred to by reference, whereas in C++ it can be
a local variable say (or directly occupy storage in another object, or
static storage). To ensure type safety -- that all member objects with
constructors have their constructors called -- the language design choice
is then between (A) not having automatic constructor calls but instead require
the equivalent of placement new for all subobjects, one can't just leave the
members as null-references as in Java, and (B) having automatic constructor
calls, in which case additional initialization in the constructor body will
be inefficient, and there is the problem of providing constructor arguments.
C++ uses solution (B), and solves the both inefficiency problem and the
argument passing problem with the constructor initializer lists mechanism.
In addition constructor initializer lists solve the problem of initializing
const members.
But an alternative to that could be not to design the language with const
members but with 'readonly' members which turn to 'readonly' state only
after the constructor has finished.
I met Stephen Wolfram, and didn't even know it at the time.
You would have been infected with cellular automata. But I rather liked
his program for displaying Sierpinski-like triangles. Since this is a C++
newsgroup, here's the Perl version, courtesy of Lars Christian Jensen:
perl -e 'for$a(0..63){for(0..$a){print($_&~$a?" ":"#")}print"\n"}'
For some reason he reminds me of the book "wheelers" by Ian Stewart... ;-)