-
Notifications
You must be signed in to change notification settings - Fork 22
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
handle of
as a binary keyword
#92
base: main
Are you sure you want to change the base?
Conversation
only match `of` as a control keyword if it is not in an if/elif/when and is followed by a colon
this doesn't allow any closing parens before the colon, and i think it could be possible to have a that be an issue. i will work on the regex more later when i have time again
ok added a small change. this doesn't allow any closing parens before the colon, and i think it could be possible to have a that be an issue. so i will work on the regex more later when i have time again |
i will likely need to figure out a regex to match balancing parens so that only a following unbalanced paren stops the match |
This makes me nervous, gonna read it over a few times, but the grammar doesn't feel right. The keyword of doesn't feel like it's being classified correctly, I think we should revise the approach. It's effectively a form of equality in each case. 🤔 Thoughts? |
it seems to me, someone a bit new to nim, that of for case is directing program flow, while in a type comparison, it’s a boolean operator. like in java, switch case and instanceof seem to me to be analogous to nim’s case of and of. two different things, in one language they have two different names, in another they have the same name |
For the case case 😁, of is saying the thing left of the case is equal to/in the lhs of the of. Hence more equality. So if we started with Which makes it effectively like a binary operator again. |
but of as an operator doesn't check equality, it checks whether a variable is of a specific type. for a case/of, you can't just stick a variable in the case and the type in the of, nim complains about the case and of being different types, even if you use the type of the variable. T vs typedesc[T] |
Not exactly equality, but it feels more like an operator than control flow in both cases. This is fuzzy stuff, it's classify syntax to a language agnostic set of categories without much semantic information. |
only match
of
as a control keyword if it is not in an if/elif/when and is followed by a colon. additionally reorderkeyword.control.nim
match|multiple|strings to be (hopefully) alphabetical ordersee #91, #90, #86