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

This proposal sounds as in-language replacement of (0, expr) hacky syntax? #57

Open
koteisaev opened this issue Dec 10, 2021 · 1 comment

Comments

@koteisaev
Copy link

Hello!
Lately I was intrigued with the need to use syntax like (0, expr) for imports from modules to make sure it does not called on module import as this.
So, what exactly happen if this proposal will be adopted, and following construct will be applied:

(undefined::module1.importedFunc)("a", true, 1, ...[1,2,3]);

What if this proposal can be extended to either

module1:>importFunc("a", true, 1, ...[1,2,3]);

or

module1->importFunc("a", true, 1, ...[1,2,3]);

to explicitly say "I want to call importFunc as independent function without relation to module1 import reference", with undefined this?

May be, :> can be used to call member method with undefined this and -> to call some method with left operand of this, like

module1:>importedFunc("a", true, 1, ...[1,2,3]);
//call `importedFunc` with `this` set to `window`
window->module1.importedFunc("a", true, 1, ...[1,2,3]);
//here call `module1.libFactory` first decoupled from `module1` import
window->(module1:>libFactory().importedFunc)("a", true, 1, ...[1,2,3]);

Thanks for reading this.

@ljharb
Copy link
Member

ljharb commented Dec 10, 2021

That seems like a different proposal, and I’m very skeptical that there’s a use case for it outside of transpiler output, since in actual user code, this is done by destructuring the function in one statement, and calling it in the next.

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

2 participants