www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Purity and enum

reply simendsjo <simendsjo gmail.com> writes:
Not sure if this is a bug, or just some missing functionality of pure.

void f() pure {
   enum a = to!string("a"); // some legal compile-time to!()
}

Gives "to is not pure"

The following works:

template S(alias v) {
   enum S = to!string(v);
}
void g() pure {
   enum a = S!"a";
}

Should purity be checked at all if used with an enum?

Tested on dmd 2.057 / linux x64
Feb 06 2012
parent reply "Daniel Murphy" <yebblies nospamgmail.com> writes:
"simendsjo" <simendsjo gmail.com> wrote in message 
news:jgo9if$1mg9$1 digitalmars.com...
 Should purity be checked at all if used with an enum?

I don't think so. http://d.puremagic.com/issues/show_bug.cgi?id=6169 https://github.com/D-Programming-Language/dmd/pull/652
Feb 06 2012
parent reply simendsjo <simendsjo gmail.com> writes:
On 02/06/2012 11:46 AM, Daniel Murphy wrote:
 "simendsjo"<simendsjo gmail.com>  wrote in message
 news:jgo9if$1mg9$1 digitalmars.com...
 Should purity be checked at all if used with an enum?

I don't think so. http://d.puremagic.com/issues/show_bug.cgi?id=6169 https://github.com/D-Programming-Language/dmd/pull/652

Thanks. Fixed in 2.059 perhaps? A long wait :)
Feb 06 2012
parent "Daniel Murphy" <yebblies nospamgmail.com> writes:
I wouldn't hold my breath.

"simendsjo" <simendsjo gmail.com> wrote in message 
news:jgoejk$23j1$1 digitalmars.com...
 On 02/06/2012 11:46 AM, Daniel Murphy wrote:
 "simendsjo"<simendsjo gmail.com>  wrote in message
 news:jgo9if$1mg9$1 digitalmars.com...
 Should purity be checked at all if used with an enum?

I don't think so. http://d.puremagic.com/issues/show_bug.cgi?id=6169 https://github.com/D-Programming-Language/dmd/pull/652

Thanks. Fixed in 2.059 perhaps? A long wait :)

Feb 06 2012