Syntactic Sugar for Virtual Constructors?

Janice Caron caron800 at googlemail.com
Thu Feb 28 07:47:19 PST 2008


On 28/02/2008, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
> what about static opCall?

Ooh - I never thought of that. That's close.

In the past, what I've done is to build a standalone function (not a
member function) called new_MyClass(), which is only an underscore
different from the standard "new" function. Ditching the word "new"
altogether is attractive.

But to clarify - it's the syntactic sugar of being able to say

    new AbstractBaseClass(...)

(and end up with a derived class) that I was asking for. I am well
aware that we already have the functionality, but the point of the
request /is/ the sugar. It's not that I want the syntax to be "simpler
than it is now", or something, it's that I want it to be /identical/
other uses of new. It's just one of those nice little touches that
would make D seem more cool. :-)



More information about the Digitalmars-d mailing list