Uh... destructors?

Steven Wawryk stevenw at acres.com.au
Thu Feb 24 16:25:24 PST 2011


On 24/02/11 14:47, dsimcha wrote:
> On 2/22/2011 12:13 AM, Jonathan M Davis wrote:
>> On Monday 21 February 2011 20:46:56 %u wrote:
>>> Hi,
>>>
>>> I'm just curious... why is saying something like this:
>>>
>>> extern(C)
>>> private static const pure override final synchronized ~this() { }
>>>
>>> allowed?
>>
>> dmd is pretty lax about attributes which don't apply. It generally
>> just ignores
>> them. Personally, I think that it should error on invalid attributes,
>> but for
>> some reason, that's not how it works. Of course, there could be other
>> bugs in
>> play here, but there's every possibility that the end result is
>> completely
>> valid.
>>
>> - Jonathan M Davis
>
> One point noone's apparently made yet: DMD's ignorance here is
> occasionally a boon for generic programming. For example, in some places
> in various code I write things like:
>
> void doStuff(C)(scope C callable)
>
> In this case, C can be either a delegate, a function pointer, or a class
> or struct that overloads opCall. Scope structs and function pointers
> make no sense. Scope delegates mean that the delegate does not escape
> the scope of doStuff(), so no closure allocation is needed. If I had to
> write two separate functions to handle cases like these it would be a
> **huge** PITA.

Aren't scope parameters deprecated and going to disappear from under 
your feet?



More information about the Digitalmars-d mailing list