News for hackers. Stuff that matters.
Re:Rust is surprisingly expressive by seth1010 on Saturday December 28, 2013 @02:56PM (#6976154)
While I don't think that syntax is that important, I am fond of sugar.

Because I've been working in D for a while, here's how you'd do it in D.

    import core.time: Duration, dur;
    import std.datetime: Clock, SysTime;

    Duration days(int number) {
      return dur!"days"(number);
    }

    SysTime from_now(Duration duration) {
      return Clock.currTime + duration;
    }

    void main() {
      import std.stdio: writeln;
      writeln(2.days.from_now);
    }

Runnable pastebin link: http://dpaste.dzfl.pl/9b84f820
Re:Rust is surprisingly expressive by mcguire on Saturday December 28, 2013 @07:30PM (#6977415)
I haven't really looked at D in a long time, so I'm not clear on what's going on here.

Is D allowing you to write the function call "days(2)" as "2.days"?

(As an aside, Nimrod allows you to do specifically that; first-arg.function-name(...) == function-name(first-arg,...).)