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

& function shorthand with template strings #887

Open
unlessgames opened this issue Dec 21, 2023 · 1 comment
Open

& function shorthand with template strings #887

unlessgames opened this issue Dec 21, 2023 · 1 comment
Labels
proposal Proposal or discussion about a significant language feature

Comments

@unlessgames
Copy link

Could be handy to be able to write

[0,1,1,2,3,5].map `some template string ${&}` 
@edemaine
Copy link
Collaborator

This seems like a natural extension of #480 ("go up a level from a bare &"). Based on the discussion there, we could plausibly even allow for `template ${&}`.toUpperCase() and other trailing content like `template ${&}` + tail (as it seems unlikely you'd want to do these operations on a function).

But where it starts to get ambiguous is if you wanted to write `template ${&.toUpperCase()}`. In the special case of template strings, it seems unlikely that you'd want to pass a function in... but with tag functions it might actually be quite useful. So perhaps this should continue to be processed as-is. (`template ${($) => $.toUpperCase()}`)

@edemaine edemaine added the proposal Proposal or discussion about a significant language feature label Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Proposal or discussion about a significant language feature
Projects
None yet
Development

No branches or pull requests

2 participants