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

Allow single case unions to be compiled as structs #293

Open
baronfel opened this issue Oct 14, 2016 · 0 comments
Open

Allow single case unions to be compiled as structs #293

baronfel opened this issue Oct 14, 2016 · 0 comments

Comments

@baronfel
Copy link
Owner

Allow single case unions to be compiled as structs [6147144]

Submitted by exercitus vir on 7/8/2014 12:00:00 AM
37 votes on UserVoice prior to migration

Single case unions are often used to define domain types that just wrap another primitive type. See http://fsharpforfunandprofit.com/posts/designing-with-types-single-case-dus/ for examples.
It would be great if we could mark these single case unions "inline" for optimized code generation. An "inline" single case union would not be converted to a class with a single "Item" property like an ordinary single case union, but instead the wrapped "Item" of the single case union would be passed directly (as is).
This would be similar to units of measure that are checked by the F# compiler, but are no longer visible in the generated code.
This would avoid the overhead of instantiating a class with the sole purpose of wrapping another type.

Response

** by fslang-admin on 8/2/2016 12:00:00 AM **

Completed
RFC here with links to implementation https://github.com/fsharp/FSharpLangDesign/blob/master/RFCs/FS-1014-struct-unions-single-case.md
Don Syme
F# Language Evolution

Original UserVoice Submission
Archived Uservoice Comments

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

1 participant