fsharp / fslang-suggestions

The place to make suggestions, discuss and vote on F# language and core library features
345 stars 21 forks source link

Enhance current Numeric Literal features #972

Open gusty opened 3 years ago

gusty commented 3 years ago

Enhance current functionality that allows custom numeric literals.

The existing way of approaching this problem in F# is using the existing feature as it is by opening a NumericLiteral module containing some specific static methods, but it has many limitations:

The proposal:

Pros and Cons

The advantages of making this adjustment to F# are:

The disadvantages of making this adjustment to F# are:

Extra information

Estimated cost (XS, S, M, L, XL, XXL): M

Related suggestions:

Affidavit (please submit!)

Please tick this by placing a cross in the box:

Please tick all that apply:

For Readers

If you would like to see this issue implemented, please click the :+1: emoji on this issue. These counts are used to generally order the suggestions by engagement.

bmitc commented 1 year ago

I would love to see some of these features implemented. Is it possible that they could be staged and done in a piecemeal fashion? For example, I think

Allow the user opening a module NumericLiteralX even when X is already in use e.g. f

is essential for the NumericLiteral feature. At present, being limited to only a handful of capital letters make the feature not usable for many applications. For example, I would like to implement a literal for dual numbers, but none of the available capital characters work for such a use case.

Also, supporting FromFloat and FromFloat32 are essential as well.

But both of these features seem to me like they could be implemented independently. With some guidance, I would be willing to try and tackle this.

bmitc commented 1 year ago

It looks like the float conversion has already been suggested and approved in principle in https://github.com/fsharp/fslang-suggestions/issues/445.