Repository navigation
1.5.0
std/math works at either float width, and floats have a conversion. Both halves of one hole, reported by a consumer who had already worked around it: std/math was single precision, a generic ECS accessor is double, and nothing converted between them — DS0232 said in words that a float had no conversions at all.
f32.nearest(v)andf64.nearest(v). One spelling per float, where an integer gets three, because an integer narrowing has three intents the compiler must not choose between and a float conversion has one: IEEE rounds to the nearest representable value, in both directions. Widening is exact and still has to be written, becauseLANGUAGE.mdpromises there is no implicit widening and a promise with an exception is one a reader has to keep a list for.- A capability may declare a parameter or return as
float, meaningf32orf64, the same one throughout the call. The width is fixed by the first argument that has one; bare literals adopt it; a call where nothing fixes it isf32. Everystd/mathandstd/timesignature is written this way, somath.clamp(v, 0, 1)works whethervis single or double precision. - Rounding moved from the standard library's implementations to the call site. These used to apply
Math.froundto every result, which stopped being correct the moment a call could be at double precision — the code protecting precision would have been the code destroying it. The compiler now wraps anf32-resolved call and leaves anf64one alone. A single-precision call emits the identical arithmetic it did before. - Diagnostics point at the conversion that exists.
DS0230on two floats namesf32.nearest/f64.nearestinstead of the three integer spellings, which used to send a reader toDS0232and a dead end.DS0263on a float-to-float mismatch names the conversion and the width the call resolved to.DS0233covers a wrong conversion method on a float; no code was renumbered and none was added. - Refused at registration rather than at a call site: a
floatreturn with nofloatparameter (nothing could fix the width, so every call would quietly bef32), a decoratedfloatsuch asfloat?, and a host type namedfloat.
A .drs file that compiled under 1.4.0 compiles under 1.5.0, to the same JavaScript, with the same diagnostics — except that f32.clamp(v) now reports DS0233 naming nearest, where it used to report DS0232 saying no conversion existed.
For a host: implement a float capability once, in double, and do not round. If you had copied std/math's old shape and were applying Math.fround inside your own implementations, that is still correct for a signature you leave written f32, and wrong for one you change to float.