local

Jon Zeppieri jaz at bu.edu
Thu Aug 21 13:45:37 PDT 2008


On Thu, Aug 21, 2008 at 4:33 PM, Peter Michaux <petermichaux at gmail.com> wrote:
>
> which is handy in a language that constantly deals with side effects.
> There is no Scheme "begin" or Lisp "progn" expression being proposed
> which means we will have to write the following pattern
>
> var y;
> let (x = 34) {
>  // side effects lines
>  document.getElementById('foo').className="n"+x;
>  // "return" y
>  y = x+4;
> }
>
> where it would be nice to write something like
>
> var y = let (x = 34) begin {
>  document.getElementById('foo').className="n"+x;
>  x+4;
> }

There are comma expressions in ES, so using a let expression:

var y = let (x = 34)
    document.getElementById('foo').className="n"+x,
    x+4;

... would do what you want, I believe.

-Jon


More information about the Es-discuss mailing list