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

Re: %and, %or, and the return value of assignment



haahr@mv.us.adobe.com (Paul Haahr) wrote:

> > As a new user of es and a professional functional programmer, I find
> > the concept of values `returning' from an expression appears to be a
> > bit broken in es, but I get the impression from initial.es that there
> > has been debate on this topic in the past.  Perhaps someone could send
> > the rationale to the list.
> 
> i'm not quite sure what your question is.  expressions in es, as in
> most languages, produce values.  the unfortunate part is that es has
> to accept shell syntax, which only provides $status as the way to
> obtain the status of the last command.  therefore, es invents a new
> mechanism:
> 
> 	<=word		# most commonly, <={command}
> 
> which means ``substitute the result of evaluating /word/ for the
> value of the whole expression.

Ah, then you haven't considered it as I have.  Imagine this:

        es              my variation
        {foo}           @{foo}
        <={foo}         {foo}
        {a;b;return c}  {a;b;c}

I would make nullary functions (code segments) explicit and return the
results of subcommands.  For example,

  a=<={b=<={c=1}}

becomes

  a={b={c=1}}

Lambda list stuff (very roughly):

  fn-cons=@ h t {@ P {$P $h $t}}
  fn-car=@ p {$p @ h t {return $h}}
  fn-cdr=@ p {$p @ h t {return $t}}
  nil=@ p {echo 'car or cdr of nil' >[1=2]; throw error}

Anyway, this is just random musing.  I don't have time to think it
through carefully at the moment, but when I do I'll write something
coherent and send it to the es list.
---
Richard Brooksby <richard@harlequin.co.uk>
ML Project / Symbolic Processing Division / Harlequin
+44 223 872522