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

Add RFC-1092 for support of System.Half #499

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

abelbraaksma
Copy link
Member

@abelbraaksma abelbraaksma commented Sep 4, 2020

See language suggestion: fsharp/fslang-suggestions#909 and discussion for this RFC: #500.

* We should take proper measures to allow FSharp.Core to be linked with other versions of .NET that do not have this type.


# Unresolved questions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chief unresolved question for me is that because this type is only available in .NET 5 and higher, we'll need to understand the best way to expose the type alias. Referencing it as System.Half is fine as that will all work according to your environment. But since type abbreviations in FSharp.Core are ultimately orthogonal, we'll have to figure it out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I put that in the discussion thread too. For this and future dependencies on features added to net core or NetStandard, we need perhaps some bespoke way to implement that in FSharp.Core so that it can still be used interchangeably with older versions too.


# Drawbacks

If we don't do this, people could still use `System.Half` directly, but don't have good language support, like overloaded conversion functions and proper compilation to IL.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to understand the current experience of using System.Half and see a comparison of what does and doesn't work when the user simply defines an alias type half = System.Half.

My belief is the experience won't be that bad but some conversions will be missing, as will a half function.

I don't know of anything that falls under the "proper compilation to IL" category.

We should be precise about the current experience.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dsyme It's been a while, but the current experience is indeed not too bad. Though users do not have formatters in sprintf and the like, nor do they have any ability for creating constants. The latter might actually be made possible if we were to allow constants of any blittable type (???).

I doubt System.Half is widely used presently. It's main use case is in CUDA and AI programming.

While I'd like this feature (and Int128, for that matter), unless we find a way to support features from .NET 6.0 and up, I don't quite see this happening: #500 (comment).

@dsyme
Copy link
Contributor

dsyme commented Jan 19, 2021

Will need to switch to RFCS-1094 or something due to erased unions grabbing the number

@kerams
Copy link
Contributor

kerams commented Apr 30, 2021

One more thing for the design section - %f in format strings will need to accept Half.

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

Successfully merging this pull request may close these issues.

4 participants