Unmanaged - a D framework on github

Benjamin Thaut code at benjamin-thaut.de
Wed Mar 20 08:50:32 PDT 2013


Am 20.03.2013 13:42, schrieb Jacob Carlborg:
> 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 {}
>

But with a regular function you always have the problem that you need to 
pass the constructor argumnets along. If there are implict conversion 
form literals to constructor arguments neccessary this will fail as soon 
as you pass them through a function.

Kind Regards
Benjamin Thaut

-- 
Kind Regards
Benjamin Thaut


More information about the Digitalmars-d-announce mailing list