Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better to introduce self keyword #41

Open
rangav opened this issue Dec 31, 2016 · 3 comments
Open

Better to introduce self keyword #41

rangav opened this issue Dec 31, 2016 · 3 comments

Comments

@rangav
Copy link

rangav commented Dec 31, 2016

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.

@saschanaz
Copy link

self is already used in web browser environment so it will be a big breaking change.

@robotlolita
Copy link

robotlolita commented Jan 3, 2017

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.someFunctionthisArgument.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.

@azz
Copy link

azz commented Jan 5, 2017

As @saschanaz mentioned, self is already a reference to the global object.

https://developer.mozilla.org/en/docs/Web/API/Window/self

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants