I found the following string literals in julia/src/julia-parser.scm
@doc_str do macrocall struct
__dot__ end memq toplevel
_cmd eqv memv true
_str false module try
abstract finally mutable tuple
bitstype for none type
block function parameters typealias
call global primitive typed_comprehension
catch if quote typed_hcat
cell1d kw ref typed_vcat
comparison line return vect
const local row where
curly macro string
which of these are officially designated as Julia Reserved Words?
Would it be possible to add the official list of reserved words to the Julia documentation?
1 Like
which of these are officially designated as Julia Reserved Words
Very few. I’m not sure how you came up with that list; it seems pretty random to me. There is a list of reserved words in the scheme global variable reserved-words
.
As I indicated, I looked at the source code file for the Julia parser (julia-parser.scm) and searched for all “hard coded” strings that start with a single quote such as 'if, 'quote, 'end, 'type, etc. (I may even have missed a few). The list contains words like 'try, 'catch, 'finally; 'mutable, 'type; 'true, 'false; macro, etc.; all of which I assume are words reserved for the Julia language.
At the other hand, I take it that “hard coded” strings like '@doc_str, cell1d, typed_hcat do not fall in the category of reserved words. I am also able to define both
const where = 1
f(x::T, y::T) where {T<:Number = …
in the same program without Julia complaining.
Hence my question: what is the official list of reserved keywords. (for proper highlighting of Julia syntax in my editor)
I looked at the variables initial-reserved-words and reserved-words in the same source file (totally missed that the first time
That is exactly what I was looking for. Thank you for pointing me to those variables.
1 Like
Just in case somebody is looking for the definition in the future:
initial-reserved-words:
begin while if for try return break continue
function macro quote let local global const do
struct
abstract typealias bitstype type immutable #to be deprecated
module baremodule using import export importall
reserved-words:
end else catch finally true false # todo: make this more complete
1 Like