3 ms·
Standard constructor boilerplate is simpler: You just wrote exactly the same thing I did, but in a style that triggers GCC warnings regarding using assignment
by ant5 16y ago
Standard constructor boilerplate is simpler:
You just wrote exactly the same thing I did, but in a style that triggers GCC warnings regarding using assignment as a truth value.
Huge advantage of this is that you can implement object pools, singletons, etc. transparently.
You might consider looking into Newspeak constructors to see how it can be (much) better done, with much less code.
In short, treat constructors as class methods, allow them to be used interchangeably, support self-types so that you can't get selector conflicts, enforce calling of the constructor so you don't have to rely on documenting the designated initializer.