In Julia, is there any function like isdynamic()
to show whether a given variable is of "dynamic" or "static" type? For example, I assume that a
and b
in the following code are dynamic and static variables, respectively, where I mean by "dynamic" that the variable can represent any data type. If I run @code_warntype, a
and b
are shown to be Any
and Int64
, respectively, but I am wondering whether it is possible to display the actual internal representation with some function. Is this not possible because the determination of the internal representation depends on the whole function (plus, the type of actual arguments when the variable depends on it) rather than the code up to the invocation of isdynamic( a )
?
function test()
a = 1
b::Int = 1
@show typeof( a ) # Int64
@show typeof( b ) # Int64
a = 3.0
b = 3.0
@show typeof( a ) # Float64
@show typeof( b ) # Int64
a = 3.2 # okay
# b = 3.2 # InexactError
end
test()
# @code_warntype test() # after eliminating @show... statements