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

Cannot interpolate a function into a method declaration. #47726

Closed
LilithHafner opened this issue Nov 28, 2022 · 2 comments
Closed

Cannot interpolate a function into a method declaration. #47726

LilithHafner opened this issue Nov 28, 2022 · 2 comments

Comments

@LilithHafner
Copy link
Member

It's possible to embed a function (not a symbol that represents the function) in an expression and execute it. It seems like it should also be possible to embed a function in an expression and define a new method for it.

julia> f() = 1
f (generic function with 1 method)

julia> eval(:($f()))
1

julia> eval(:(f() = 2))
f (generic function with 1 method)

julia> f()
2

julia> eval(:($f() = 3))
ERROR: syntax: invalid function name "Main.f" # Actual
f (generic function with 1 method)            # Desired

julia> f()
2 # Actual
3 # Desired
@LilithHafner LilithHafner added the lowering Syntax lowering (compiler front end, 2nd stage) label Nov 28, 2022
@simeonschaub simeonschaub removed the lowering Syntax lowering (compiler front end, 2nd stage) label Nov 28, 2022
@simeonschaub
Copy link
Member

That's not something we really support since the frontend will never emit such expressions. Resolved bindings like this will be represented as GlobalRefs instead.

@LilithHafner
Copy link
Member Author

Thanks. GlobalRef was what I was looking for.

@LilithHafner LilithHafner closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2022
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