Understanding isInfinite(Range)

Andrej Mitrovic andrej.mitrovich at test.com
Mon Sep 6 13:20:38 PDT 2010


Is this legal?:

enum a = "test";
a = "test2";

Because it seems to compile. But that shouldn't work afaik..?

I can't reassign other enum types:

enum b = 4;
b = 5;  // error

which is expected.

Pelle Wrote:

> On 09/06/2010 08:53 PM, Philippe Sigaud wrote:
> > On Mon, Sep 6, 2010 at 18:47, Pelle <pelle.mansson at gmail.com
> > <mailto:pelle.mansson at gmail.com>> wrote:
> >
> >     On 09/04/2010 02:11 PM, Simen kjaeraas wrote:
> >
> >             Is there a way you could write an isStatic(expr) template? Using
> >
> >
> >         template isStatic( alias T ) {
> >         enum isStatic = is( char[1+T] );
> >         }
> >
> >         unittest {
> >         int n = 3;
> >         assert( !isStatic!n );
> >         assert( isStatic!1 );
> >         enum r = 5;
> >         assert( isStatic!r );
> >         }
> >
> >
> >     enum s = "Hello";
> >
> >     assert (isStatic!s);
> >
> >     Gonna need more work than that.
> >
> >
> > Why? That's exactly the behavior we want, or so it seems to me.
> >
> >
> 
> Sorry if I was unclear, that assert fails. Due to that you cannot add an 
> integer and a string, not not that the string isn't static. It's an 
> enum, so it definitely is static.



More information about the Digitalmars-d-learn mailing list