-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
support a.$b in quoted expressions #4004
Comments
If you know that julia> type Foo
c::Int
d::Int
end
julia> a = Foo(1,2)
Foo(1,2)
julia> b = :c
:c
julia> a.(b)
1
julia> a.(:($b))
1
julia> :(a.(:($b)))
:(a.(b))
julia> eval(:(a.(:($b))))
1 |
Unfortunately, it's not as simple as that, because the
This throws an exception It seems to be unfortunately rather tricky to insert a |
Yup, that's true. I have a vague recollection of a similar discussion, but I can't seem to find it. @toivoh, do you have any thoughts? |
@kmsquire, I think that the previous discussion that you are referring to is #1540 (comment). Two thoughts:
|
I'm not a fan of the Matlabism – it's unintuitive to me that wrapping something in parens should change its meaning. |
@toivoh, yes, that was the conversation, thanks! And thanks for your input--seems reasonable to me. I believe it's undocumented behavior (I can't find it), and it probably isn't used much. |
Ok I'm going to remove the |
Ok. That change is going to need a lot of packages to change in response. I think JSON uses this. Distributions definitely does. |
Yes, I just started looking through packages and as a result I'm having second thoughts. It is used more than we thought. |
Can we deprecate it instead? |
Maybe, but it's tricky. And the abstract syntax built by |
If
b
is a Symbol anda
is a composite typeFoo
, it would be nice ifquote a.$b end
turned into access for the field$b
ofa
. However,eval
ing this gives an errortype Foo has no field $
because it parses as:(*(a.$,b))
.a.($(Expr(:quote, b)))
works, but is rather counter-intuitive.The text was updated successfully, but these errors were encountered: