On Sunday, 23 September 2012 at 20:39:38 UTC, Andrei Alexandrescu wrote:
I discussed this with Walter, and we concluded that we could deprecate the comma operator if it helps tuples. So I started with this:

http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP19

Unfortunately, I started much cockier than I ended. The analysis in there fails to construct a case even half strong that deprecating the comma operator could significantly help tuples. Well it essentially concludes that tuples are mostly fine as they are, and attempts to embellish them syntactically are marred with unexpected problems. Nevertheless, I sure have missed aspects all over, so contributions are appreciated.


Thanks,

Andrei

With removed comma operator from D next code will work?

module maybe;

import std.stdio;
import std.algorithm;

R  With(I, R)(I o, R function (I) fun)
{
        return o is null ? null : fun(o);
}

R Return(I, R)(I o, R function (I) fun, R failureResult)
{
        return o is null ? failureResult : fun(o);
}

I If(I)(I o, bool function (I) fun)
{
        return o is null ? null : fun(o) ? o : null;
}

I Unless(I)(I o, bool function (I) fun)
{
        return o is null ? null : fun(o) ? null : o;
}

I Do(I)(I o, void function (I) fun)
{
        return o is null ? null : fun(o), o;
}

void doit(string value)
{
        writeln("Loading... \n");
}


void main()
{
        string name = "D";

        name = name.With((string x) => "Hello, " ~ x ~ "!").
                                If((string x) => canFind(x, "D")).
                                Do((string x) => x.doit).
                                Return((string x) => x ~ " I love You!", "Oh, 
my!");
        
        writeln(name);
}


especially template function

I Do(I)(I o, void function (I) fun)
{
        return o is null ? null : fun(o), o;
}

Reply via email to