Syntactic Sugar for Virtual Constructors?

Christopher Wright dhasenan at gmail.com
Thu Feb 28 07:20:06 PST 2008


Janice Caron wrote:
> Now bear in mind that MyClass is an /abstract/
> class. It can never be constructed. Only subclasses can be
> constructed, and that, of course, is the job of a factory. What I'm
> suggesting, then, is just syntactic sugar. It won't give us anything
> we can't do already, but it will let us do it with a nicer syntax.

But in a fragile way, and bound to the language. A library solution that 
takes the pain out of writing factories would be more general, more 
flexible, and less work for Walter. And, hey, it probably does 80% of 
what you need, today. Except for you having to map IANA strings to 
classes. And since major dependency injection libraries don't support 
this, you're SOL: it's not enough of a use case to include there, so it 
certainly isn't enough of a use case for a language solution.



More information about the Digitalmars-d mailing list