is (which should be the same as in the third expression?)
:($(1+2))
And I expect its behavior is the same as:
Expr(:$,:(1+2))
But it obviously doesn’t support my expectation.According to the manual, it says the construction using Expr() and :() should be the same, but why are they different in such a case?
Just because the construction using :() will be default interpolated
:($(1+2))
But the construction using Expr() will not be interpolated?
Which part of the manual? There’s no such guarantee. :() is not the syntax for creating expressions, it’s the syntax for quoting. There are many other cases where :() does not even create Expr objects so the two cannot possibly be equivalent.
There’s also no guarentee that there’s a quoting syntax to create all possibly valid expressions.
The second syntactic purpose of the : character is to create expression objects without using the explicit Expr constructor. This is referred to as quoting . The : character, followed by paired parentheses around a single statement of Julia code, produces an Expr object based on the enclosed code
He said that “The : character, followed by paired parentheses around a single statement of Julia code, produces an Expr object”.
I don’t know whether the statement is saying :() is equivalent to Expr()?
I agree that doc can be confusing, and you are certainly not the first one confused by it. You are certainly welcome to improve it though bear in mind that it also needs to be understandable for people reading it the first time and doesn’t want to worry about all the details yet…
OTOH, I do believe it is correct, in that it more or less implies : can be used to create corresponding Expr but it doesn’t imply the mapping is complete. In that sense, yes, the reason your expectation break down is that $(1 + 2) isn’t a valid expression for you to quote.
Please don’t open new topics for the same question, especially if you got an answer (if the answer is not satisfactory, just say so and hopefully others will respond and clarify).
OK.
I am sorry to break the rules of community, and I will try my best to understand the manual as far as possible, when I have a confusing question about the explanation in the manual.
Sorry again!