How do I get keyword information for the version of Julia being run?
For example, there are 33 keywords in Python 3.6, but only 31 in 2.7:
# This is Python 3.6 code running in a file:
import keyword
print(len(keyword.kwlist))
## Output: 33
# This is Python 2.7 code running in a file:
import keyword
print len(keyword.kwlist)
## Output: 31
Can this kind of check be done in Julia? Or does someone have a different suggestion for getting info on Julia keywords for the running version?
EDIT:
Thanks to responses below I have gotten some interesting suggestions. However, something seems to be missing. For example, in each list of reserved words provided below, the word elseif is missing. Am I to believe that elseif is not a keyword (or reserved word)?
Also when I go to the Scheme code where intial-reserved-words and reserved-words come from, I find the following code:
(define initial-reserved-words '(begin while if for try return break continue
function macro quote let local global const do
struct
module baremodule using import export))
(define initial-reserved-word? (Set initial-reserved-words))
(define reserved-words (append initial-reserved-words '(end else catch finally true false))) ;; todo: make this more complete
At the end of the last line above is the comment:
;; todo: make this more complete
This seems to imply that even the union of intial-reserved-words and the reserved-words lists (or whatever they are called in Scheme) is not complete.
Thus, I have held off on checking one of the answers. I will be happy to check one when I see how to get a canonical list of Julia reserved words in Julia code. If a Julia expert believes one of the suggestions below is the best way to get the list of keywords (reserved words) for the current version of Julia, I would appreciate knowing it.