1. When I said "we need to do something about it", I had something in mind
like `12f` instead of `12'f32` which is what we have now for several versions.
2. Most of `math.nim` supports both floats and doubles.
3. `Vector3d` etc need to be made generic, no language change required.
That said, I keep thinking about a feature to set the default type for integer
and float literals module-wide.
import macros, typetraits
proc replace(n: NimNode; dest: NimNodeKind): NimNode =
if n.kind == nnkFloatLit:
result = newNimNode(dest)
result.floatVal = n.floatVal
else:
result = copyNimNode(n)
for i in 0..<n.len: result.add replace(n[i], dest)
macro f32Lits(n: untyped): untyped = replace(n, nnkFloat32Lit)
proc foo(a, b: float32) {.f32Lits.} =
echo type(a + 0.34).name
proc bar(a, b: float32) =
echo type(a + 0.34).name
foo(0.5f, 0f)
bar(0.5f, 0f)
**Note**: This requires the most revent devel version of Nim because of a bug
in the lexer.