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

Allow do blocks for keyword arguments #46109

Open
LilithHafner opened this issue Jul 19, 2022 · 1 comment
Open

Allow do blocks for keyword arguments #46109

LilithHafner opened this issue Jul 19, 2022 · 1 comment
Labels
keyword arguments f(x; keyword=arguments) kind:feature Indicates new feature / enhancement requests parser Language parsing and surface syntax

Comments

@LilithHafner
Copy link
Member

sort(x, by = x -> -sqrt(x))
sort(x, lt = (x, y) -> (println("comparing $x and $y"); isless(x, y)))

could become

sort([1,2,3]) by = do x
    -sqrt(x)
end
sort([1,2,3]) lt = do x, y
    println("comparing $x and $y")
    isless(x, y)
end

Motivated by #44633

@LilithHafner LilithHafner added keyword arguments f(x; keyword=arguments) kind:feature Indicates new feature / enhancement requests labels Jul 19, 2022
@JeffBezanson JeffBezanson added the parser Language parsing and surface syntax label Jul 26, 2022
@JeffBezanson
Copy link
Sponsor Member

Very interesting idea. It requires looking ahead 2 tokens, since we need to match <identifier> = do, but I think this is currently always an error after a function call expression, so it seems do-able 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keyword arguments f(x; keyword=arguments) kind:feature Indicates new feature / enhancement requests parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

2 participants