turtles features (Was: Flag proposal)

Timon Gehr timon.gehr at gmx.ch
Mon Jun 13 17:11:11 PDT 2011


Andrei Alexandrescu wrote:
> module my_module;
>
> void fun()
> {
>      import std.random;
>      return uniform(0, 100);
> }
>
> int gun()
> {
>      import std.stdio;
>      writeln(fun());
> }
>
> This module won't compile in today's D, but not for a matter of
> principles; it's just a random limitation of the language. (It does work
> if you import from within a class or struct.) You can insert most
> declarations in a scope, so the ones you can't insert are just awkward
> exceptions, unless there's a good reason to actively disable them. Any
> code should work if you just wrap another scope around it.


//void main(){
    immutable a = b;
    immutable b = 1;

    int foo(int n){
        if(n==1) return 1;
        return 1+bar(n);
    }

    int bar(int n){
        if(n&1) return foo(3*n+1);
        return foo(n/2);
    }
//}

Will this be fixed too?

Timon


More information about the Digitalmars-d mailing list