Enum that can be 0 or null

Alex Parrill via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 20 19:43:29 PDT 2016


On Saturday, 21 May 2016 at 02:04:23 UTC, Mike Parker wrote:
> On Saturday, 21 May 2016 at 01:09:42 UTC, Alex Parrill wrote:
>
>>
>> Looks like my best bet is to mark it as deprecated and point 
>> them to Vk(Type).init instead.
>
> I would prefer to do something like this:
>
> enum VK_NULL_HANDLE_0 = 0;
> enum VK_NULL_HANDLE_PTR = null;
>
> Then document it clearly. Alias VK_NULL_HANDLE to one of them 
> and keep it deprecated forever. Many users are not going to 
> read the documentation on their own initiative, so the 
> deprecation message telling them how to solve the problem will 
> save you from responding to the same issue again and again and 
> again.

Hm, I could do `VK_NULL_DISPATCHABLE_HANDLE = null` for the types 
that are always pointers and `VK_NULL_NONDISPATCHABLE_HANDLE = 
null ? IS_64BIT : 0` for types that are either pointers are 
integers depending on arch, but those names are a bit long. Your 
specific example wouldn't work.


More information about the Digitalmars-d-learn mailing list