Open rangav opened 7 years ago
self
is already used in web browser environment so it will be a big breaking change.
JS already has a self
parameter, which we call this
.
::
solves a different problem, namely invoking a function while providing an explicit this
parameter (as in thisArgument::someFunction(other, args, here)
→ someFunction.call(thisArgument, other, args, here)
), and constructing a new function whose this
parameter is bound (as in ::thisArgument.someFunction
→ thisArgument.someFunction.bind(thisArgument)
).
As far as I know most languages don't allow you to provide an explicit this
argument, since most languages don't allow you to get the method's function directly, so this isn't a problem that could exist in those languages. Python is one of the few exceptions that come to mind (as well as Lua and JavaScript, of course).
The ::
operator is somewhat close to infix application in languages like F#, by the way, where arg1 |> someFunction(arg2)
is the same as someFunction(arg1, arg2)
. The major difference is that it uses the implicit this
parameter to pass that first argument, instead of the first positional argument.
As @SaschaNaz mentioned, self
is already a reference to the global object.
I think it's better to introduce self keyword for this as its already used in other languages like Swift and ruby. So it's easier to adopt.
:: is really terrible to use and looks ackward to read the syntax.
Please don't make JavaScript hard to read.