Fully transitive const is not necessary

Janice Caron caron800 at googlemail.com
Wed Apr 2 00:05:05 PDT 2008


On 02/04/2008, Janice Caron <caron800 at googlemail.com> wrote:
> Global variables will /not/ be reachable from a pure function. Example:
>
>     int g;
>
>     pure int f()
>     {
>         return g; /*ERROR*/
>     }
>
>  The above will not compile, because global variables won't be
>  available to pure functions.

However, I suspect that the following will be OK.

    enum g = 42;

    pure int f()
    {
        return g;
    }

I'm only guessing here - I don't have any inside knowledge. But it
seems reasonable to me that global compile-time constants declared
outside the function ought to be available inside it. I guess we'll
just have to wait and see.

But global variables - no.



More information about the Digitalmars-d mailing list