anonymous:

The compiler doesn't know that f's return value is unknown to the rest of the world, because f isn't marked pure. And, indeed, make f pure and it just works: int[] f() pure {return [1, 2, 3];} immutable v = f();

Awesome!

"purity" seems a simple idea, but if you try to implement it "well" in a system language as D you quickly learn that it's composed of *many* parts. You have hit one of its many parts. Each of those part was invented by someone, designed, implemented (often by Hara), tested... :-)

Some small parts of D purity are not yet fully implemented, you see part of them here:
http://d.puremagic.com/issues/buglist.cgi?quicksearch=pure
http://d.puremagic.com/issues/buglist.cgi?quicksearch=purity

Bye,
bearophile

Reply via email to