-
Notifications
You must be signed in to change notification settings - Fork 3
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
Switch to more local @_
#26
Comments
Oh that's pretty magical, I didn't know we could return "naked" tuples. Splat at production not consumption. Mathematica has something like this, but I thought Julia didn't. julia> map(@_ _^2, [1 2 3])
1×3 Matrix{Int64}:
1 4 9
julia> @macroexpand1(@_ _^2, [1 2 3])
:(((var"##x#301"->begin
#= REPL[12]:12 =#
var"##x#301" ^ 2
end), [1 2 3])...)
julia> dump(ans)
Expr
head: Symbol ...
args: Array{Any}((1,))
1: Expr
head: Symbol tuple |
I feel quite silly because I've known we could do this for years, but never made the connection that it could be used to bypass JuliaLang/julia#36547 |
Is this documented anywhere? |
Since this would be a major departure from how this package works, I think I'll close this in favour of just making a new package: https://github.com/MasonProtter/SimpleUnderscores.jl |
Sounds good! |
So I realized here: JuliaLang/julia#38713 (comment) that we actually can have
map(@_ 1 + _[1], v)
or whatever do the right thing. Maybe this should be the canonical usage of this macro instead of being outside themap
.The text was updated successfully, but these errors were encountered: