Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reserved words in julia-parser.scm #29197

Closed
bkamins opened this issue Sep 14, 2018 · 7 comments
Closed

Reserved words in julia-parser.scm #29197

bkamins opened this issue Sep 14, 2018 · 7 comments
Labels
parser Language parsing and surface syntax

Comments

@bkamins
Copy link
Member

bkamins commented Sep 14, 2018

There seem to be the following reserved words missing in julia-parser.scm:

  • mutable, abstract, primitive in initial-reserved-keywords;
  • elseif, type, where in reserved-words.

Maybe it is intentional and I am not sure how relevant this is and if I have classified them correctly.

However, the source says in todo comment that the list should be completed so I am reporting this.

@ihnorton ihnorton added the parser Language parsing and surface syntax label Sep 15, 2018
@JeffBezanson
Copy link
Member

mutable, abstract, and primitive are not reserved; they're only special when followed by type or struct. type is also not reserved for the same reason. where is resolved contextually and so it's also not really reserved; it can be used as a variable name.

I think elseif could be added to the list without changing any parsing.

@bkamins
Copy link
Member Author

bkamins commented Sep 17, 2018

Thanks for explanation. The only ambiguity I would guess it introduces is:

julia> primitive = 10
10

julia> type = 100
100

julia> [primitive type]
ERROR: syntax: unexpected "]"

but it is handled correctly.

I will add elseif to reserved-words to check if anything fails and I guess @JeffBezanson can decide if it is worth to merge it.

@bkamins
Copy link
Member Author

bkamins commented Sep 17, 2018

@mbauman Regarding your doc tag in #29222:

I think it would be good to document what @JeffBezanson put down in this issue as it is not obvious but I am not sure what would be the best place for it (probably somewhere around https://docs.julialang.org/en/latest/base/base/#Keywords-1).

@mbauman
Copy link
Member

mbauman commented Sep 17, 2018

The brief intermittent doc tag was just a bad prior on my part: I assumed the change must be documentation because surely elseif is already reserved in the parser. The next step in my review was actually looking at the code… :)

Yeah, it seems like that Keywords section could use just a brief introduction about what those words all are.

@bkamins
Copy link
Member Author

bkamins commented Sep 17, 2018

OK - I will try to add an appropriate section as I have seen this question popping up.

@JeffBezanson
Copy link
Member

Just to clarify, it's worth noting that the parser doesn't actually need a list of all the "reserved" words in one place, since they don't all have the same parsing. We also need to distinguish words that are fully reserved and can't be used as variable names, from those that are mostly free to use but have some special syntax associated with them.

@bkamins
Copy link
Member Author

bkamins commented Sep 17, 2018

Understood (hopefully 😄). I have tried to capture documentation of this distinction in #29229.

@bkamins bkamins closed this as completed Sep 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

4 participants