Miguel Bazdresch
unread,Apr 13, 2012, 9:41:11 AM4/13/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to juli...@googlegroups.com
Hi,
I'm working on adding argument validation to Gaston; I want to make it as hard as possible to get gnuplot errors or warnings from Gaston commands. Since I'm learning Julia in the process, I wondered how much the type system could help me to achieve this. Reading the manual, I found this in the "types" section, regarding the :: operator:
The “declaration” behavior only occurs in specific contexts:
x::Int8 # a variable by itself
x::Int8 = 10 # as the left-hand side of an assignment
However, trying this out in Julia:
julia> x::Int
x not defined
julia> x::Int8 = 10
x not defined
julia> x = 1
1
julia> x::Int
1
julia> x::Int = "boo"
"boo"
However, this seems to work:
julia> function foo()
x::Int
x = "boo"
end
julia> foo()
no method convert(Type{Int64},ASCIIString)
in method_missing at base.jl:60
in foo at prompt:3
Why does :: seem to work for declarations inside functions, but not outside them?
-- mb