-
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
Doesn't with ternary operators #18
Comments
The macro needs to be outside the function to which you pass the anonymous function, as in julia> @_ map(_ == 'X' ? 0 : 1, collect("XYZ"))
3-element Array{Int64,1}:
0
1
1 These aren't meant to work: julia> @_ (_+1)
ERROR: syntax: all-underscore identifier used as rvalue
julia> @_ _ == "X" ? 0 : 1 #doesn't work
ERROR: TypeError: non-boolean (var"#7#8") used in boolean context although it seems like the second one does trigger some transformation. It's possible that since the ternary operator doesn't "look like a function call" #12, , the macro ought to recurse inside, to make a function inside julia> @macroexpand @_ (_+1)
:(_ + 1)
julia> @macroexpand @_ _ == "X" ? 0 : 1
:(if ((_1,)->begin
_1 == "X"
end)
0
else
1
end)
julia> any(>(3), 1:4) ? "yes" : "no"
"yes"
julia> @_ any(_>3, 1:4) ? "yes" : "no"
ERROR: TypeError: non-boolean (var"#13#14") used in boolean context |
This doesn't work either
Basically, I am gonna give u on Underscores.jl it's not intuitive at all how these rules work. |
This one expands to
where the However I guess you wanted something else, for this DataFrames syntax? xref #16 for discussion of that. |
The below doesn't work
but this works
The text was updated successfully, but these errors were encountered: