let-in if do-expr is problematic? (was: Re: proposal: let in if parentheses)

kai zhu kaizhu256 at gmail.com
Wed Aug 22 12:12:55 UTC 2018


es6 import-statements are effectively with-statements …

actually, they're *async* with-statements, with no callback-handling and
non-obvious dependency-resolution logic, for those of us trying to debug
them when things go wrong.

On Aug 22, 2018 15:58, "Claude Pache" <claude.pache at gmail.com> wrote:

>
>
> > Le 21 août 2018 à 21:20, Herbert Vojčík <herby at mailbox.sk> a écrit :
> >
> > Hi!
> >
> > It would be nice to know if do expressions have some a chance, otherwise
> some other syntax for let-in would be really helpful, especially now that
> we have arrow functions.
> >
> > I would propose to use different variant of let (maybe also const):
> >
> > OP 1:
> >
> >  let in a = b(), if (a) a.c();
> >
> > OP 2:
> >
> >  let in a = b(), if (a) c(a);
> >
> > Instead of
> >  const big = raw => {
> >    let cooked = cook(raw);
> >    return consumer => {
> >      // do things with consumer and cooked
> >    };
> >  };
> >
> >  const big = raw =>
> >    let in cooked = cook(raw), consume => {
> >      // do things with consumer and cooked
> >    };
> >
> > In short,
> >
> >  let in binding = expr, stmt|expr
> >
> > It may work for `const in` as well.
> >
> > Herby
> >
> > P.S.: Alternative syntax is "let a=3, b=4, ..., in foo(a,b,c,d)" but
> this can only tell late if it is plain let-up-to-end-of-scope or
> local-scope-let, so not sure if that may be a problem; OTOH you can chain
> more of them and resembles classical let-in better.
>
> Please, don’t take it too seriously: but have you thought about
> resuscitating the (in)famous `with` statement?
>
> ```js
> const big = raw =>
>     do with ({cooked: cook(raw)})
>         consumer => {
>             // do things with consumer and cooked
>         };;
> ```
>
> And no the two ”;”s are not a typo: I need to end both the `with`
> statement and the `const` declaration.
>
> But more seriously... those sorts of “clever” syntaxes (`let-in` or
> `do-with` or whatever), apart from complicating the language, are in danger
> of raising as much issues than they’re resolving; the double-semicolon
> oddity is one of them.
>
> —Claude
>
> _______________________________________________
> 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/20180822/0d07cb54/attachment.html>


More information about the es-discuss mailing list