standard alias for a class name inside the class code?
dan via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat May 28 17:14:17 PDT 2016
Is there a standard alias for a class name inside class code?
Something like 'this' referring to a class instance, but
referring instead to the class itself?
What i would like to do is have something like
class Clas {
// alias Clas THIS; <- don't want this boilerplate
static THIS make_instance( .... ) {
auto x = new THIS( );
....
return x;
}
}
This would be great for copy/paste, changing class names, and in
general communicating your intention.
I'm guessing the answer is no, and that there's some compelling
reason why a compiled language wouldn't want to provide this
feature. (But the php interpreter, whatever else is good or bad
about it, does let you write 'new self(...)' and does the right
thing with it.)
TIA for any clues.
dan
More information about the Digitalmars-d-learn
mailing list