Swift style syntax
rosyatrandom at gmail.com
Tue May 7 11:35:18 UTC 2019
I've always been partial to operators merely being functions with
infix/whatever sugar; having operators without there being a corresponding
function seems deeply weird.
Dammit babies, you've got to be kind.
On Tue, 7 May 2019 at 05:58, Ates Goral <ates at magnetiq.com> wrote:
> This topic has been discussed a long time ago and has stalled on
> discussions of a standard library.
> Coming back to the idea of adding some basic math operations directly
> on Math, there could be value in adding at least the following (from
> Isiah Meadows's post):
> > - `a + b` -> `Math.add` -> `:+`
> > - `a - b` -> `Math.sub` -> `:-`
> > - `a * b` -> `Math.mul` -> `:*` (different from `imul`)
> > - `a / b` -> `Math.div` -> `:/`
> `Math.add`: Among potentially other things, this could be useful for
> an out-of-the-box, terse way to add up items in an array. So, instead
> array.reduce((sum, item) => sum + item);
> Items could be added up with:
> `Math.sub`: Among potentially other things, this could be useful for
> sorting numbers without having to define a custom comparator (i.e. almost
> lexicographically sorting numbers by using the default sort
> implementation.) So, instead of:
> array.sort((first, second) => first - second);
> Numbers could be sorted with:
> `Math.mul` and `Math.div`: I don't have a compelling use case in mind,
> but I'd just throw these in for good measure / symmetry.
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss