extern(C++) and struct (constness mangling problem ?)

Timon Gehr timon.gehr at gmx.ch
Wed Nov 30 05:58:44 PST 2011


On 11/30/2011 01:54 PM, deadalnix wrote:
> Le 30/11/2011 13:30, Timon Gehr a écrit :
>> On 11/30/2011 11:57 AM, deadalnix wrote:
>>> Le 30/11/2011 03:07, Andrei Alexandrescu a écrit :
>>>> On 11/29/11 2:22 PM, Timon Gehr wrote:
>>>>> The default initializer can easily be disabled:
>>>>>
>>>>> struct S{
>>>>> int x;
>>>>> @disable this();
>>>>> @disable void[0] init;
>>>>> @disable this(this);
>>>>> }
>>>>>
>>>>> Now nobody can do
>>>>> auto x = S.init;
>>>>>
>>>
>>> @disable void[0] init; Sound hacky as hell. Is it made by design, or is
>>> it a consequence of the current compiler implementation ?
>>>
>>
>> Built-in properties can be hidden (I am almost sure it is by design),
>> void[0] just means 'field with size 0' and is explicitly allowed by the
>> language specification. @disable is by design as well. I orthogonally
>> combined those three features in order to disable the built-in .init
>> property.
>>
>
> Yes, I understand that, but the property belong to the struct, not each
> instance, so it should not work unsless it is static. Am I wrong ?

Interesting point. @disable just disables a symbol. This precedes any 
type checks. It works because it is not possible to overload a symbol 
based on 'static'.


More information about the Digitalmars-d mailing list