Pipe-Syntax?

Manfred Nowak svv1999 at hotmail.com
Tue Dec 20 20:51:13 PST 2011


Just looked at index.html of D and got stuck on

    writeln("Hello World, Reloaded");

    // auto type inference and built-in foreach
    foreach (argc, argv; args)
    {
        // Object Oriented Programming
        auto cl = new CmdLin(argc, argv);
        // Improved typesafe printf
        writeln(cl.argnum, cl.suffix, " arg: ", cl.argv);
        // Automatic or explicit memory management
        delete cl;
    }

With the pipe-syntax of shells ( sh, bash, ...) this five lines could be
written as: 

    "Hello World, Piped" | writeln;
    args | CmdLin | {argnum, suffix, " arg: ", argv} | writeln;

Comments?

-manfred


More information about the Digitalmars-d mailing list