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

consider unifying value and type cases #1296

Open
gavinking opened this issue May 12, 2015 · 2 comments
Open

consider unifying value and type cases #1296

gavinking opened this issue May 12, 2015 · 2 comments

Comments

@gavinking
Copy link
Member

In an of clause we write stuff like of x | y | Type. Why can't we write that in a case?

Currently Ceylon forces you to distinguish type cases from value cases using the is keyword, which very occasionally pushes you towards nastiness like this:

case (is \Itrue | \Inull | Foo) { … }

Are there any really compelling reasons to not let you just write:

case (true | null | Foo) { … }

Historically, I think there were some reasons, since I had speculated about a lot of different kind of case conditions, case (satisfies ... ), etc, which we still don't have. Also the syntax for value cases was different to the syntax for union types with the ,s instead of |s.

Right now, I can't really think of much.

@luolong
Copy link
Member

luolong commented May 12, 2015

I think it might have been an artifact of treating case's as conditionals and thus making them closer in syntax with if statements.

Also, wasn't is Foo supposed to be doing some sort of type narrowing along the way?

@gavinking
Copy link
Member Author

I think it might have been an artifact of treating case's as conditionals and thus making them closer in syntax with if statements.

Well, they're not defined as conditions in the spec.

Also, wasn't is Foo supposed to be doing some sort of type narrowing along the way?

Well, sure, that's what it does, of course, but now even value cases affect flow-sensitive typing (they narrow the else clause).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants