[Prev][Next][Index][Thread]

Re: small Q



>>>>> "Bruce" == Bruce Hoult <bruce@hoult.org> writes:

    Bruce> In article <398F745E.33516CAC@worldnet.att.net>, bstewart@bix.com 
    Bruce> wrote:

    >> In fact, it occurs to me that a nice extension to the language would be
    >> to allow more than two procedures in call-with-values - each procedure's
    >> (values ..) form would supply arguements to the procedure to its right,
    >> forming a kind of pipeline. It would certainly be easier to read than
    >> the normal composition of nested function calls.

    Bruce> In Dylan you need to do this as multiple statements:

    Bruce> let (a, b, c) = foo();
    Bruce> let (d, e)    = bar(a, b, c);
    Bruce> let (f, g, h) = baz(d, e);

That would be 

  foo->bar->baz->(f,g,h)

in BETA and gbeta.  It is actually quite useful, also when the
pipelines get more complex:

  ((a,b)->foo->(bar,baz),c)->quux->(d,e->f)

Since the reading direction and the data-flow direction are the same,
this can be read in a consistent manner: "evaluate a and b, give it to
foo, then (bar,baz)".  Or focusing at the higher level: "evaluate 
((a,b)->foo->(bar,baz),c), give it to quux, then (d,e->f)".  Compare
this with 

  let (x1,x2,x3) = foo(a,b);            // assuming foo yields 3 results
  let (x4,x5) = bar(x1);                // assuming bar ..
  let x6 = baz(x2,x3);                  // assuming baz ..
  let (d,e) = quux(x4,x5,x6,c);
  let f = e;

If "d" and "e" are methods then we'd have to use 

  let (x7,x8) = quux(x4,x5,x6,c);
  d(x7);
  f(e(x8));

Now try to read that at the higher level...

In these languages, pipelines and tuples form the basis for a uniform
expression of "function call", "method invocation", "assignment",
"expression evaluation" and lots of other things whose expression is
often quite inhomogeneous in traditional syntaxes.

Note that an expression like "foo->bar" would still work without
changes even if foo is changed to deliver another tuple of results and
"bar" is changed to accept another tuple of arguments.  It would be
checked at compile-time that those two tuples were still compatible,
of course.


  regards,

-- 
Erik Ernst                                    eernst@cs.auc.dk
Department of Computer Science, University of Aalborg, Denmark



References: