Open rfourquet opened 3 years ago
I think that's a difficult one. I don't think it can be done in a non-breaking way for 1.x, because I am pretty sure a lot of macros and the like assume homoiconicity of floating point literals. Theoretically, it would be possible to either just parse this as a string macro, or as a special expression type that gets transformed to a literal during lowering in 2.0, but it would likely also make any other kind of metaprogramming with floating point literals harder.
Default floating point literals are interpreted as
Float64
and is lossy:I'm not proposing to change the above behavior by default, but to allow macros to have access to the original string, i.e.
"1.0000000000000001"
here, similar to how the AST stores a string forInt128
,UInt128
andBigInt
literals. Currently we getThis means that a macro has access to the original typed string for
Int128
, but not forFloat64
. Changing that would allow macros (like in theSwapLiterals
package) to reinterpret a float literal to a more exact type thanFloat64
, be itBigFloat
or an exact decimal format.