Reputation: 2922
I asked myself the simple question in the title.
Here are the results:
julia> # Fresh 1.0.0 REPL
julia> VERSION
v"1.0.0"
julia> 2
2
julia> code_lowered(ans)
0-element Array{Union{Nothing, CodeInfo},1}
How can ans
be a 0-element
array to represent a 2?
Any suggestions?
Upvotes: 0
Views: 46
Reputation: 69939
code_lowered
expects a callable as a first argument. Clearly 2
is not callable so it returns array of zero IR, because there exist none for non-callable. Try code_lowered(Int)
or code_lowered(sin)
to see that all works fine (first is a type and second is a function - two basic kinds of callables).
It has nothing to do with ans
. It just checks what ans
contains, e.g.:
julia> f() = 10
f (generic function with 1 method)
julia> code_lowered(ans)
1-element Array{Core.CodeInfo,1}:
CodeInfo(
1 1 ─ return 10 │
)
julia>
Upvotes: 4