www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Issue 6169

Pure functions in D keep producing new and new ideas. There are some
purity-related ideas yet to be implemented, but (I think) accepted by Walter,
like allowing an implicit cast to const of the result of a strongly pure
function, or generating an error if you don't assign the result of a strongly
pure function to a variable. And there is my not so much appreciated idea of
the  transparent too (and maybe there are other ideas I don't remember at the
moment).

A new idea has just appeared in Bugzilla, by Timon Gehr:
http://d.puremagic.com/issues/show_bug.cgi?id=6169

It asks to allow code like this too, where a pure function calls a impure one
and assigns the result with enum:

int x = 10;
int foo(bool b) {
    if (b)
        x++;
    return 0;
}
pure void main() {
    enum y = foo(false);
}


After thinking some about it, I think it's acceptable. See my comment in the
bug report for more info.

Bye,
bearophile
Jun 16 2011