Open gusty opened 3 years 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.
It looks like the float
conversion has already been suggested and approved in principle in https://github.com/fsharp/fslang-suggestions/issues/445.
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:
X
is already in use e.g.f
NumericLiteral
aloneFromDecimal
which would return a tuple of two BigIntegers, the first element being the number before the '.' and the second the decimal part.FromInt
over-5N
will return-5
. This behavior is a bit unexpected, it should ideally return5
and then once the literal is resolved, apply (if defined) the unary-
operator. Correcting this will allow restricting our custom number domain to positives.Pros and Cons
The advantages of making this adjustment to F# are:
L
,.0
or.0m
and excessive overload of operators.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.