Optional Curly Braces in JavaScript

Ed Saleh medozs at outlook.com
Sun Nov 3 20:48:13 UTC 2019


Hi,
We can convert the curly braces less style back to curly braces blocks when minifying. We can enforce that style also through linting. Making this new style of using colon spacing for block would be an option to use a certain situations. It basically like
`if(foo) bar()` and `if (foo){bar()}`. The brace less idea is building on the former.
Thank you,
________________________________
From: es-discuss <es-discuss-bounces at mozilla.org> on behalf of kdex <kdex at kdex.de>
Sent: Sunday, November 3, 2019 3:39:48 PM
To: es-discuss at mozilla.org <es-discuss at mozilla.org>
Subject: Re: Optional Curly Braces in JavaScript

Note that significant whitespace greatly minimizes the yields of minification as
well, which doesn't matter much for languages like Python, but starts to
matter as soon as you're forced to send your source code over the network,
expecting something to appear on the screen in a few hundred milliseconds. In
this sense, this proposal is counterproductive.

On Sunday, November 3, 2019 9:36:26 PM CET Ed Saleh wrote:
> If it's possible in JavaScript to have `:`, and enable significant spacing,
> that would be great. ________________________________
> From: es-discuss <es-discuss-bounces at mozilla.org> on behalf of Ed Saleh
> <medozs at outlook.com> Sent: Sunday, November 3, 2019 3:34:09 PM
> To: Bergi <a.d.bergi at web.de>; es-discuss at mozilla.org
> <es-discuss at mozilla.org> Subject: Re: Optional Curly Braces in JavaScript
>
> Why you don't *want* to? I didn't force you to like my proposal. I am just
> posting my ideas for feedback, not see who wants and doesn't want to like
> it. ________________________________
> From: es-discuss <es-discuss-bounces at mozilla.org> on behalf of Bergi
> <a.d.bergi at web.de> Sent: Sunday, November 3, 2019 3:17:11 PM
> To: es-discuss at mozilla.org <es-discuss at mozilla.org>
> Subject: Re: Optional Curly Braces in JavaScript
>
> Hi Ed!
>
> > Update to the proposal:
> >
> > Since we can't make spaces in JavaScript, the best we can do is use '_'
> > instead.
> You misunderstood. We *could* make use of significant whitespace in
> JavaScript (enabled by the `:` instead of a brace after a statement) -
> we just don't *want* to.
>
> That said, `_` is not a workable solution - apart from _ (and any
> repetitions of it) being a valid identifier already, *chaining* it like
> you described doesn't work with nested blocks:
> ```
> for (const x of [1,2,3])
> _ if (x % 2)
>   _ console.log('odd')
> _ console.log(x)
> ```
> would be indistinguishable from
> ```
> for (const x of [1,2,3])
> _ if (x % 2)
>   _ console.log('odd')
>   _ console.log(x)
> ```
> (and no, please don't suggest repetion of whatever token you come up
> with for signifying nesting level)
>
> kind regards,
>  Bergi
> _______________________________________________
> 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/20191103/f1eed382/attachment.html>


More information about the es-discuss mailing list