tc39 / proposal-extended-numeric-literals

Extensible numeric literals for JavaScript
https://tc39.github.io/proposal-extended-numeric-literals/
72 stars 18 forks source link

Pipeline operators #14

Closed leobalter closed 6 years ago

leobalter commented 6 years ago

I was trying to collect some possible operators to use instead of any valid identifier name to use in the numeric extensions. At some point I ended up realizing the current proposal for the pipeline operator might be already fixing this use case:

50 |> px (desugaring to px(50)). The only thing to blame here is the double characters operator if not anything else.

There are some other perks her: it's possible to write this code in multiple lines or just a single line as also chaining this to other calls.

Feels like the current proposal only offers some sort of factory (Object.freeze({ string, number })) which can be built in functionalities of whatever method I'm passing the numbers to.

rwaldron commented 6 years ago

which can be built in functionalities of whatever method I'm passing the numbers to.

I suspect the reason for specifying this to explicitly send { string, number } was to allow authors to write groups of digits (to the left of the extension) that may represent a value that cannot be represented in double-precision floating-point format. I suspect that passing only a string containing the group of digits would satisfy this requirement, eg. 50 |> px desugars to: px("50")

littledan commented 6 years ago

Yes, the current proposal also supports caching like template string literals, something that @dherman raised as important.