How do I defeat the gratuitous qualification of alias members?

Tobias Pankrath tobias at pankrath.net
Fri Apr 5 11:06:53 PDT 2013


On Friday, 5 April 2013 at 18:03:33 UTC, Chad Joan wrote:
> On 04/05/2013 01:48 PM, Chad Joan wrote:
>> On 04/05/2013 01:18 PM, Andrej Mitrovic wrote:
>>> On 4/5/13, Chad Joan<chadjoan at gmail.com> wrote:
>>>> Enums do not have instances.
>>>
>>> Sure they do.
>>>
>>> enum Foo
>>> {
>>> X,
>>> Y
>>> }
>>>
>>> void test(Foo foo) { }
>>>
>>> void main()
>>> {
>>> Foo foo = Foo.Y;
>>> test(foo);
>>> }

foo is the instance.

> I can probably word this another way, since I might not have 
> been entirely clear.
>
> Things like structs and classes occupy memory.  Enums do not.  
> Foo.Y expands to an immediate value and has no storage in the 
> program's data segment.  Enums place constraints on other 
> things that do occupy memory: usually integers.

foo does occupy memory. That foo is represented just like an 
integer does not change this. foo could be a struct or an array, 
too.


More information about the Digitalmars-d-learn mailing list