W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2013

Re: Non-agression pact for the JS runtime namespace territory

From: David Bruant <bruant.d@gmail.com>
Date: Mon, 19 Aug 2013 01:03:51 +0200
Message-ID: <521152D7.9080204@gmail.com>
To: Jake Verbaten <raynos2@gmail.com>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
Le 19/08/2013 00:44, Jake Verbaten a écrit :
> Why can't we just avoid namespace collisions completely using our 
> module system
> ```js
> import { find, findIndex } from "@array";
> var res = find([1, 2, 3], (n) => return n === 2)
> ```
We don't even need modules. Underscore is already this that with success [1]
The "problem" is that people want to do [1,2,3].find( n => n === 2 )

> If necessary we
we "TC39"?
a non-standard extension for things like TypeScript?

> can have syntax sugar for importing symbol methods instead of 
> functions. Or maybe implement the syntax sugar as some kind of infix 
> function call operator so you can call functions as if they are methods
> `[1, 2, 3]@find((n) => return n === 2)`
The definition of x@y(...args) is y.call(x, ...args) right? That's an 
interesting idea. This very syntax seems to collide with relationships 
[2], but maybe another syntax could work.

But I am skeptical of any idea that requires adding syntax to the 
language, because it pushes further in time the solution.
And since a library author can't force every library user to use a given 
tool (transpiler), I'm afraid library authors will prefer defining 
things on Array.prototype directly so everyone can use them right away.


[1] http://underscorejs.org/#find
[2] http://wiki.ecmascript.org/doku.php?id=strawman:relationships

Ps : totally unimportant, but "(n) => return n === 2" is a syntax error. 
I think the form without brackets need the RHS to be and expression and 
"return something" is a statement or something like that.
Received on Sunday, 18 August 2013 23:04:21 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:18 UTC