Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use keywords in syntax #287
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
Use keywords in syntax #287
Changes from all commits
7423759
29b87b8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think
{}
brackets are better than[]
ones because of the need to quote inside the literal.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack. The wording here is just being consistent with the rest of the doc in its current state. I know that #255 is still very much open.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't care for the use of
when
proposed here. I don't see what value it adds. All of the selectors are clearly part of thematch
statement. Thewhen
is just extra noise which actually obscures the values.Note that I still favor delimiting the selectors and the literal. The selector delimiter functions the same way that
when
does--identifying that there is an set of values in thematch
.The single-line example (below, line 143) could then be like:
Or (without delims):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see two benefits to
when
:It allows us to add more keywords in the future that come after the last variant, e.g.
meta
orattribute
. Usually, programming languages solve this by putting the body of the statement inside a curly-brace-delimited block, but I think we said we didn't want to risk people forgetting the closing brace.(This one is more subjective) It creates a visual correspondence between the
match
and each variant, in particular in case of multiline messages.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack here as well. I'm not opposed to delimiting variant keys, but it's true that I'm still hoping that we can use square brackets
[...]
for delimiting patterns (#255).Technically, I think just relying on order here is good enough:
match <selector list> <variant list> <pattern value> <variant list> <pattern value>
is OK from the parser's point of view, unless we anticipate some other productions to follow all variants in the future (see point 1 in my comment just above).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let
is clear enough, but I think there's an opportunity here to use a keyword that directly relates to the name that we choose for these let bindings (#248). This would be self-explanatory and easier to learn and search for. For example:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
let
is fine, as it says "immutability" (if you come from JS, if not, then "tough luck")From your list I also like
macro
andalias
, as they are suggest "things you declare for convenience, something shorter, that you use to not repeat again and again something long"The rest (
decl
andexpr
) are too generic.And I think that
macro
andalias
are more familiar thanlet
, for a lot more people than JS devs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this PR is now closed, let's use #289 to continue this topic.