Cyril Auburtin (2016-11-05T10:15:49.000Z)
Do expressions seems like another thing like `=> ({ })` to fix the mess
with curly braces (used for expressions or objects litterals)

```js
var f = x => ({ foo: 1}); // need () there, but we get used to it.
var f = { x: {foo: 1} }; // no need for ()
```
But do expressions seems the less bad way  (= would be confusing), to solve
things like format1 below
```js
format1({
html() {   // unecessary function to wrap expressions
doSomething(...);
res.send('..')
},
json() {
//...
},
})
format2({
html: (()=>{   // bit ugly with iifes
doSomething(...);
res.send('..')
})()
})
format2({
html: do { // do expressions proposal
doSomething(...);
res.send('..')
}
})
format2({    // if you have just one statement, is it stricly equivalent to
do { res.send('...') } ?
html: res.send('..')
})
```

2016-11-01 16:46 GMT+01:00 Isiah Meadows <isiahmeadows at gmail.com>:

> Beat you to it by about a year ;-)
>
> https://esdiscuss.org/topic/generalize-do-expressions-to-
> statements-in-general
>
> And to be quite honest, I did find it got some interest from TC39, but it
> was one of them IIRC that pointed out the ambiguity with `do { ... } while
> (...)`, in which the fix would require no line terminator between the `}`
> and `while`, but it wasn't particularly elegant. Keep in mind they are
> interested (V8 implements the original proposal behind a flag FWIW), but
> it's the parsing difficulty that's the blocker. I'm currently writing up an
> alternative strawman right now that would probably end up a little more
> intuitive. (Loops will trip up way too many people with the current
> semantics, for example.)
>
> On Tue, Nov 1, 2016, 09:21 JongChan Choi <jong at chan.moe> wrote:
>
> > there isn't much difference from the `do expression`, actually, it might
> be worse since it looks confusing. if it can not be omitted, I'd rather
> stay with `do`.
>
> I thought omitting additional brackets(`var foo = = if (cond) { bar } else
> { baz }`) was most sweet spot in this proposal than do expressions.
> what do you think about `var foo = do if (cond) { bar } else { baz };`?
>
> > 2016. 11. 1., 오후 4:10, Yongxu Ren <renyongxu at gmail.com> 작성:
> >
> > Isiah, In your case, if we do
> > ```
> > var x = = { a }
> > ```
> > there isn't much difference from the `do expression`, actually, it might
> be worse since it looks confusing. if it can not be omitted, I'd rather
> stay with `do`.
> >
> > The intent for this proposal is to allow writing better functional code
> in javascript. IMO, the `do expression` is a good start, but I think using
> `=` (and other operators) is a more elegant since it can be omitted.
> >
> > Actually, I think I have a better idea to put it together:
> >
> > *1. besides defining a function, if the block can be legally be replaced
> by an expression, while otherwise it would cause parsing error, convert it
> to expression block*
> >
> > *2. if the case is ambiguous or it is been used in function declaration,
> adding `=` (actually, using `do` here isn't a bad idea either, but can be
> quite ugly for defining function) will enforce block to be parsed as
> expression*
> >
> > The goal is to make javascript more functional friendly.
> >
> >
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20161105/dcc36ef4/attachment-0001.html>
cyril.auburtin at gmail.com (2016-11-05T10:22:50.530Z)
Do expressions seems like another thing like `=> ({ })` to fix the mess with curly braces (used for expressions or objects litterals)

```js
var f = x => ({ foo: 1}); // need () there, but we get used to it.

var f = { x: {foo: 1} }; // no need for ()
```
But do expressions seems the less bad way  (= would be confusing), to solve
things like format1 below
```js
format1({
  html() {   // unecessary function to wrap expressions
    doSomething(...);
    res.send('..')
  },
  json() {
    //...
  },
})
format2({
  html: (()=>{   // bit ugly with iifes
    doSomething(...);
    res.send('..')
  })()
})
format2({
  html: do { // do expressions proposal
    doSomething(...);
    res.send('..')
  }
})
format2({    // if you have just one statement, is it stricly equivalent to do { res.send('...') } ?
  html: res.send('..')
})
```

2016-11-01 16:46 GMT+01:00 Isiah Meadows <isiahmeadows at gmail.com>:
cyril.auburtin at gmail.com (2016-11-05T10:22:05.286Z)
Do expressions seems like another thing like `=> ({ })` to fix the mess with curly braces (used for expressions or objects litterals)

```js
var f = x => ({ foo: 1}); // need () there, but we get used to it.

var f = { x: {foo: 1} }; // no need for ()
```
But do expressions seems the less bad way  (= would be confusing), to solve
things like format1 below
```js
format1({
  html() {   // unecessary function to wrap expressions
    doSomething(...);
    res.send('..')
  },
  json() {
    //...
  },
})
format2({
  html: (()=>{   // bit ugly with iifes
    doSomething(...);
    res.send('..')
  })()
})
format2({
  html: do { // do expressions proposal
    doSomething(...);
    res.send('..')
  }
})
format2({    // if you have just one statement, is it stricly equivalent to
  do { res.send('...') } ?
  html: res.send('..')
})
```

2016-11-01 16:46 GMT+01:00 Isiah Meadows <isiahmeadows at gmail.com>:
cyril.auburtin at gmail.com (2016-11-05T10:21:41.928Z)
Do expressions seems like another thing like `=> ({ })` to fix the mess with curly braces (used for expressions or objects litterals)

```js
var f = x => ({ foo: 1}); // need () there, but we get used to it.

var f = { x: {foo: 1} }; // no need for ()
```
But do expressions seems the less bad way  (= would be confusing), to solve
things like format1 below
```js
format1({
html() {   // unecessary function to wrap expressions
  doSomething(...);
    res.send('..')
  },
  json() {
    //...
  },
})
format2({
  html: (()=>{   // bit ugly with iifes
    doSomething(...);
    res.send('..')
  })()
})
format2({
  html: do { // do expressions proposal
    doSomething(...);
    res.send('..')
  }
})
format2({    // if you have just one statement, is it stricly equivalent to
  do { res.send('...') } ?
  html: res.send('..')
})
```

2016-11-01 16:46 GMT+01:00 Isiah Meadows <isiahmeadows at gmail.com>: