New enum features

Sivo Schilling i-b-p at gmx.net
Mon Jan 7 14:11:14 PST 2008


torhu Wrote:

> Sivo Schilling wrote:
> > Is there a difference between an anonymous enum member and a manifest
> > constant considering a string?
> 
> I tried it with an int array, seems that's broken too.  I'm hoping for a 
> bugfix release soon, so we can try out the features properly. :)
> 
> ---
> import std.stdio;
> 
> enum int[] array = [1, 2, 3];
> 
> void main()
> {
>     writefln(array); // ok, prints [1, 2, 3]
> 
>     foreach (x; array)  // access violation with 2.009
>        writefln(x);
> }
> ---

I´ve got the same results with your code. But with a small
modification your code works without any error messages:

---
import std.stdio;

enum {int[] array = [1, 2, 3]}

void main()
{
    writefln(array); // ok, prints [1, 2, 3]

    foreach (x; array)  
       writefln(x);
    // ok, prints
    // 1
    // 2
    // 3 
}
---

So, I believe the reason could be bracketing or no bracketing? 
But trying the latter case is it a bug ?

Regards



More information about the Digitalmars-d mailing list