Re: Re: Strict (non-coercing) expressions

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Strict (non-coercing) expressions

Bruno Jouhier
I like the idea of a block level annotation. Lighter and more practical than a new set of operators. Module level would be nice too. OTOH expression level feels a bit like overkill.

Why not turn this into a more general _pragma_ syntax then? This would allow us to control other special conditions: throw on overflow, on divide by zero, etc.



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Strict (non-coercing) expressions

Mark S. Miller-2
On Thu, Apr 13, 2017 at 11:08 AM, Bruno Jouhier <[hidden email]> wrote:
I like the idea of a block level annotation. Lighter and more practical than a new set of operators. Module level would be nice too. OTOH expression level feels a bit like overkill.

Why not turn this into a more general _pragma_ syntax then?

We already have a pragma syntax. So how about

"use coercions, not!";

Just kidding about the actual text, but this "use x"; pragma pattern was meant to be usable for more than just "use strict";. This pragma syntax was designed to be ignored on versions of the language that do not yet recognize the pragma. Such version compat seems appropriate for the issue we're discussing.

 
This would allow us to control other special conditions: throw on overflow, on divide by zero, etc.



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



--
    Cheers,
    --MarkM

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Strict (non-coercing) expressions

Bruno Jouhier
In reply to this post by Bruno Jouhier
“use …”, of course!
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Strict (non-coercing) expressions

Bruno Jouhier
In reply to this post by Bruno Jouhier
The "use ..." syntax could be extended to expressions:

```js
const foo = "use !div-by-0" && bar / zoo;
```


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Strict (non-coercing) expressions

Isiah Meadows-2
Just a quick FYI, *nobody* on TC39 likes adding directives known to
the core language - they aren't too keen on Perl's tendency towards
them.
-----

Isiah Meadows
[hidden email]


On Fri, Apr 14, 2017 at 2:42 AM, Bruno Jouhier <[hidden email]> wrote:

> The "use ..." syntax could be extended to expressions:
>
> ```js
> const foo = "use !div-by-0" && bar / zoo;
> ```
>
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Strict (non-coercing) expressions

Bruno Jouhier
In reply to this post by Bruno Jouhier
I don't know the ins and outs of the "nobody likes", I'll just respond as a "language user".

We do not expect `NaN` in 99.99% of our code, and we do not expect infinities in 99.95% of it. Instead of having these values creep unnoticed though the computations (and else branches executed because tests are silently false) it would be better to have them turned into exceptions (fail fast). 

With a pragma I would just set the fail fast default at the top of every module and override it in the few functions where special values are expected. Impact will be low and code will remain _familiar_.

With a new set of operators, I'll have to replace the operators (almost) everywhere in the code. I'll also have to create a new lint rule to enforce the new operators everywhere, and I'll need to introduce a lint directive for the exceptions. Big impact and code will look _strange_.

Obviously I prefer the pragma solution but I don't really care about the pragma syntax. If "use ..." does not cut it there are other ways (contextual `pragma` keyword?).

Bruno

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Strict (non-coercing) expressions

Rick Waldron


On Sat, Apr 15, 2017 at 7:02 AM Bruno Jouhier <[hidden email]> wrote:
I don't know the ins and outs of the "nobody likes", I'll just respond as a "language user".

The committee, which is now comprised of more practitioners/language users than runtime implementors and academics combined, has done everything it possibly can for 8 years (ES5 was first published in 2009) to avoid introducing new directives. 

Rick
 

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Strict (non-coercing) expressions

Bruno Jouhier
In reply to this post by Bruno Jouhier
Fine. I'm -1 on this feature if it means adding whole sets of new operators, and +1 if it can be implemented with a directive. So -1 it will be.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Loading...