A few simple syntactic proposals
Robert Fraser
fraserofthenight at gmail.com
Thu Apr 17 01:23:20 PDT 2008
Scott S. McCoy wrote:
> On Wed, 2008-04-16 at 17:38 -0700, Robert Fraser wrote:
>> 2. Allow interfaces that are not sub-interfaces of IUnknown to be
>> explicitly "delete"d.
>
> Could you maybe elaborate on this a bit? Maybe it's just because I
> don't yet have the full D 2.0 proposed specification memorized, but what
> on earth are you talking about? :-)
Sure. Say you have this:
""
interface Lolcat { }
class Happycat : Lolcat { }
int main(string[] args)
{
Lolcat cat = new Happycat();
// ...
delete cat; // Right now, this is illegal
}
""
The proposal is to make it legal to explicitly delete instances of an
interface. It is illegal right now because interfaces can refer to a COM
interface, which is not managed by D memory. But all COM interfaces are
sub-interfaces of IUnknown so it's known at compile-time that they are
so, thus the restriction can be applied only to them.
Also, the more I think about it, extern(C++) interfaces might not be
easily deletable, but again this is known at compile time, so delete can
be restricted on them as well.
More information about the Digitalmars-d
mailing list