-
Notifications
You must be signed in to change notification settings - Fork 1
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
Syntax for trait uses
clauses
#36
Comments
Because of alias and uses clauses, we should have separate top-level uses clauses. Off the top of my head, I don't think we have any syntax anywhere that is a keyword followed by a comma-separate list of expressions. |
|
Here is my suggestion from the original post: The first option (multiple uses clauses) looks like this
The second option has one uses clause, and looks like this
Note that in this second example, the uses statement is a single statement on one logical line. If we allow multiple comma-separated aliases, then they would need to be parenthesized to avoid ambiguity. |
The real question is: how does either perform when things get even bigger:
vs
I thought we talked about this somewhere else too: the point being that if we want to support multiple keywords (for use, exclude, alias) in these clauses, it's simple not to also support lists in that keyword. |
OK, you have persuaded me to allow multiple uses, each with a single trait. But you have raised other issues: should we allow multiple alias clauses, or just one? Should we allow multiple exclude clauses, or just one? Must alias come before exclude (my assumption), or exclude before alias (your assumption), or is the order semantically relevant and therefore up to the programmer? |
and not multiple traits per uses?
some of this is in #43. The order probably is relevant. I think it needs to be alias then exclude, so you can exclude the name you just aliased. But I'm not sure. |
multiple uses, each with a single trait, not multiple traits per uses. |
so according to the protocol I wrote last week, this shouldn't be closed, but should be moved from "now" to "resolved, to be specd". which I've now done. sorry. |
I was looking over James' notes from the Pomona meetings to see if I could find out what we said about the trait uses syntax.
The first option looks like this:
The second option looks like this
The advantage of the first option, where each
uses
is separate, is that when theuses
statements get long (with severalalias
andexclude
clauses), they are clearly separated. The disadvantage is that they appear to be "executed" sequentially, rather than being composed and combined into the new object all at once. This syntax also introduces a new syntax error, when not all of theuses
statements appear together.The second option does a better job of expressing that all of the used traits are composed together "in parallel", but might get messy (requiring parenthesis and continuation lines) when there are several
alias
andexclude
clauses on each.Andrew
The text was updated successfully, but these errors were encountered: