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

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



[i wrote about expressions returning values]

> Does this require
>	x=<={y='foo'}
> or
>	x=y='foo'
> ?

the former, though i've received a request to support the latter through
syntax munging.

> 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.

the only serious debate i remember about this was over the syntax
of the operator that is now known as <=; it used to be <> before
that became the ``open file for reading and writing'' redirection
operator.  in my opinion, <= is visually better, but that's minor.
it's main feature is that is otherwise not legal es syntax.

paul