How do I defeat the gratuitous qualification of alias members?

Chad Joan chadjoan at gmail.com
Fri Apr 5 11:03:33 PDT 2013


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);
>> }
>
> Where's the instance?
>
> All I see is
>
> void test(int foo) { }
>
> void main()
> {
> int foo = 1;
> test(foo);
> }
>
> There is no stateful aggregation for me to see here.

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.


More information about the Digitalmars-d-learn mailing list