Julia: Cannot declare symbols starting with a number using the ':' character

Created on 31 May 2016  Â·  4Comments  Â·  Source: JuliaLang/julia

julia> :9A
ERROR: UndefVarError: A not defined
 in eval(::Module, ::Any) at ./boot.jl:225
 in macro expansion at ./REPL.jl:92 [inlined]
 in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46

julia> :aA
:aA
doc

Most helpful comment

Maybe Stefan's answer from here - http://stackoverflow.com/questions/23480722/what-is-a-symbol-in-julia - can be edited and added to the manual.

All 4 comments

This is to be expected, the : is for quoting Julia code, and not only for symbol literals. So only valid Julia identifiers can be retrieved as symbols this way. If you want to create other symbols, you have to use Symbol.

OK. Should be documented though.

Maybe Stefan's answer from here - http://stackoverflow.com/questions/23480722/what-is-a-symbol-in-julia - can be edited and added to the manual.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StefanKarpinski picture StefanKarpinski  Â·  3Comments

musm picture musm  Â·  3Comments

StefanKarpinski picture StefanKarpinski  Â·  3Comments

tkoolen picture tkoolen  Â·  3Comments

i-apellaniz picture i-apellaniz  Â·  3Comments