-
Notifications
You must be signed in to change notification settings - Fork 34
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
inline variable in switch #1119
Comments
Initial implementation of this is in branch Also still requires updates to the spec and tests. |
I did it here… but it won’t hurt much if the switch introduces a new variable instead of assigning to an existing variable. |
:-( Whenever I think "surely no-one has ever done this", it always turns out that someone has done it, and I break their code. |
Eh, the code isn’t even a week old, you don’t have to feel bad about breaking that :D And I agree that very few people are likely to have done that. |
We can now declare inline variables in switch.
Update for ceylon/ceylon-spec#1119: Inline variable in switch.
This still needs a spec. I'm on it! |
Spec is done. Closing! |
Closes #70.
Previously, I had been avoiding adding support for the rather convenient form
switch (val=expression())
because it is in principle ambiguous:val=expression()
is a legal expression. However, I just noticed that we let the syntaxtry (resource=expression())
slip into the language, which features the same in-principle ambiguity.I don't think either of these is truly ambiguous in any meaningful sense: the semantic distance between an assignment and an inline variable specification is not very large, and I anyway don't think anyone writes assignments in
switch
ortry
.So I'm inclined to allow this syntax in both
switch
andtry
. If anyone disagrees with my analysis, then we should disallow the syntax in both places.The text was updated successfully, but these errors were encountered: