You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
The text was updated successfully, but these errors were encountered: