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

Be able to convert from integers to C-like enums #1648

Closed
kevina opened this issue Jan 24, 2012 · 4 comments
Closed

Be able to convert from integers to C-like enums #1648

kevina opened this issue Jan 24, 2012 · 4 comments
Labels
A-typesystem Area: The type system C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@kevina
Copy link
Contributor

kevina commented Jan 24, 2012

Now that we can specify explicit discriminant numbers (see #1393) it would be nice to be able to convert from integers to the C-like enums. Doing so safely will likely require some sort of run-time check.

@kevina kevina closed this as completed Jan 24, 2012
@kevina kevina reopened this Jan 24, 2012
@kevina
Copy link
Contributor Author

kevina commented Jan 24, 2012

Can the typestate system be used in this context?

@fzzzy
Copy link
Contributor

fzzzy commented Jan 25, 2012

+1

@graydon
Copy link
Contributor

graydon commented Feb 16, 2012

I wouldn't try to wire this in to typestate yet. It does not yet support literals and, even when it did, this would be an extension above and beyond. I'd just make it a dynamic failure if you try to cast and the range is wrong, at least for now. It's an easy sort of lint to prohibit.

@catamorphism
Copy link
Contributor

Dup of #2132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

4 participants