Emulate C's (polymorphic) NULL type

ParticlePeter via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 6 11:36:47 PDT 2016


On Monday, 6 June 2016 at 18:33:36 UTC, ParticlePeter wrote:
> On Monday, 6 June 2016 at 16:19:02 UTC, Alex Parrill wrote:
>> On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote:
>>> In C NULL can be used as integer as well as null pointer.
>>> Is there a way to create such a type in D?
>>>
>>> The type should have only one value which is obviously 
>>> (0/null).
>>> A extern( C ) function should be able to take it as either 
>>> one.
>>>
>>> Overloaded enum pops into my mind as example:
>>> enum NULL = 0;
>>> enum NULL = null;
>>>
>>>
>>> Is this possible somehow?
>>
>> I already asked about this: 
>> https://forum.dlang.org/post/bnkqevhyxwdjjxscteus@forum.dlang.org
>>
>> Tldr; doesn't seem to be possible without multiple alias this 
>> or using ABI hacks.
>
> O.k., my web search didn't find that topic. The last reply 
> looks promising, wouldn't that work?

Lets bump it and discuss there.


More information about the Digitalmars-d-learn mailing list