Unmanaged - a D framework on github

Jacob Carlborg doob at me.com
Wed Mar 20 05:42:09 PDT 2013


On 2013-03-20 08:57, Benjamin Thaut wrote:

> You still can't replace evertything with custom alloc templates and have
> nice syntax. There are at least two cases where it does not work nicely:
>
> 1) Arrays (no new T [size] syntax)
> 2) Inner classes (a template can't automatically capture the outer class)
>
> So I think overloading new and delete actually has its place. But the
> way it is currently implemented in D is useless in my eyes.

Instead of having a special keyword like we have now. We could have, as 
has been suggested before, a regular function or method.

With a class, there's also the possibility to return a different type or 
a singleton:

class Foo
{
    Foo new ()
    {
        return Bar.new();
    }
}

class Bar : Foo {}

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list