Is this behavior expected?
julia> dump(Expr(:macrocall, :@inbounds))
Expr
head: Symbol macrocall
args: Array{Any}((1,))
1: Expr
head: Symbol macrocall
args: Array{Any}((1,))
1: Symbol @inbounds
typ: Any
typ: Any
Why are there 2 macrocall
s?
This is in contrast to:
julia> dump(:(@inbounds nothing))
Expr
head: Symbol macrocall
args: Array{Any}((2,))
1: Symbol @inbounds
2: Symbol nothing
typ: Any
Maybe:
julia> dump(:@inbounds)
Expr
head: Symbol macrocall
args: Array{Any}((1,))
1: Symbol @inbounds
typ: Any
julia> dump(Expr(:macrocall, Symbol("@inbounds")))
Expr
head: Symbol macrocall
args: Array{Any}((1,))
1: Symbol @inbounds
typ: Any
2 Likes
Btw, it gets even weirder in v0.7. Any idea how to build an @inbounds
block in nightly? The following is my source of confusion.
julia> ex = Expr(:macrocall, Symbol("@inbounds"), :(a[1] = 1))
:(@inbounds)
julia> dump(ex)
Expr
head: Symbol macrocall
args: Array{Any}((2,))
1: Symbol @inbounds
2: Expr
head: Symbol =
args: Array{Any}((2,))
1: Expr
head: Symbol ref
args: Array{Any}((2,))
1: Symbol a
2: Int64 1
typ: Any
2: Int64 1
typ: Any
typ: Any
julia> dump(:(@inbounds a[1] = 1))
Expr
head: Symbol macrocall
args: Array{Any}((3,))
1: Symbol @inbounds
2: LineNumberNode
line: Int64 1
file: Symbol REPL[107]
3: Expr
head: Symbol =
args: Array{Any}((2,))
1: Expr
head: Symbol ref
args: Array{Any}((2,))
1: Symbol a
2: Int64 1
typ: Any
2: Int64 1
typ: Any
typ: Any
It seems the only difference is the line info, which I shouldn’t really need. Any help is appreciated.
Yes you do. You must provide them.
So which line is this referring to? I am making an expression in a generated function that uses an @inbounds
block. So is it the line where I pushed the @inbounds
expression to the block, or some other line? And does this mean if I press enter or rearrange functions, that I have to manually edit this all over the file!!!? Please tell me I am misunderstanding this.
Whereever the user can find how the code is generated.
So ideally, yes.
I mean, you can. But there’s @__LINE__
.
1 Like