On Thu, Jun 12, 2003 at 04:02:50PM +0200, Rafael Garcia-Suarez wrote: > Nicholas Clark wrote: > > > > class Foo { > > ... > > std::size_t spare = 0 > > std::size_t allocate = 4096 > > std::size_t min_readline = 80 > > > > and have the compiler know that if I specify a member initialiser in my > > my constructor, then that should be used, otherwise to default to using > > the value I say. (To avoid the inevitable search/replace if I want to > > change that value) > > That's actually valid Java syntax (modulo a trailing C<;>). The default > value can be any expression (as long as it doesn't involve a reference > to the object being constructed, IIRC). > > In fact Java provides a notion of instance initialiser, run before > any specific constructor you're invoking, that initialises such fields, > and may run other code.
This wasn't quite what I was thinking about. I was more for typing laziness (and avoiding cut&paste) - I'd like a default for the instance initialiser, but only to be used (by the compiler's code generator) if I don't specify a specific initialiser in that (overloaded) constructor. But currently I'm having my mind warped by C++, so I may not be sane. Nicholas Clark