From e0947adb2a46d6ffb5de149196b6bc23a60a61f3 Mon Sep 17 00:00:00 2001
From: Joseph Ferano
The prelude is written in Flan and prepended to every program, so nothing in it -needs importing. Printing is deliberately not a primitive: +
The prelude is written in Flan, all but one line of it, and prepended to every
+program, so nothing in it needs importing. Printing is deliberately not a primitive:
write-stdout is the one output primitive and everything above it is
ordinary Flan.
i32swap-i32!, reverse-i32!, sort-i32!, index-of-i32, min-i32, max-i32, sum-i32bytes=?, starts-with?, ends-with?, index-of-byte, index-of-bytes, trim, digit?, space?parse-i64, parse-f64sign-f32, lerp, floor-f32, ceil-f32, round-f32, sqrt-f32sign-f32, lerp, floor-f32, ceil-f32, round-f32, and sqrt-f32, which is the one declare in the filerand-seed, rand-u32, rand-f32, rand-i32-range, rand-f32-rangestrtoll answers 0 for "", 0 for
"abc" and 12 for "12x", which are three wrong answers a caller
cannot tell from a real 12.
+sqrt-f32 goes the other way, and is the one function in the file that
+is not Flan: (declare sqrt-f32 [x f32] f32 "sqrtf"). Every other number
+here is reachable from the four operations and a cast; a square root is not, and the
+usual trick of seeding Newton's method from the exponent bits needs a bit-cast between
+f32 and u32 that the language does not have. IEEE-754 makes
+sqrt correctly rounded, so libm gives the same bit pattern on both targets
+anyway — the very property that keeps the RNG in Flan is, for this one, the argument
+for going out to C. It is also why every link carries -lm.
There is no println. There is no overloading yet, so each printer names
its type. The names are the compiler's answer too: (println 1) is
unknown function println.