D vs. placement new (for classes) aka why D needs .sizeof and
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Sun Apr 15 12:25:32 PDT 2007
David B. Held wrote:
> Chris Nicholson-Sauls wrote:
>> [...]
>> Uhm... except that we have them already? Or is this not what you meant:
>>
>> # interface IToString {
>> # public char[] toString () ;
>> # }
>> #
>> # auto obj = new class IToString {
>> # public char[] toString () { return "<anonymous class>"; }
>> # };
>
> Hmm...that's pretty cool. I guess that is needed for Java
> compatibility, huh?
>
> Dave
I assume that's why we got them. I really don't remember what justification Walter gave
for them at the time, but it was probably a requested thing. Although honestly, the one
thing I used this often for in Java was event handlers... and in D we have the
oh-so-beautiful delegates to do that sort of thing. Plus the three or so Signals/Slots
implementations floating around, which are also beautiful. So I have trouble thinking of
any really compelling use for anonymous objects.
-- Chris Nicholson-Sauls
More information about the Digitalmars-d
mailing list