Say that two formatted numbers cannot be held at once
This commit is contained in:
parent
cb47b98100
commit
b23bd8e377
15
NEXT.md
15
NEXT.md
@ -714,6 +714,21 @@ Sixty mutations, nineteen left the whole suite green. The severe cluster is clos
|
||||
|
||||
## Sharp edges
|
||||
|
||||
- **Two formatted numbers cannot be held at once.** `flan_i64_to_bytes`, `flan_f64_to_bytes` and `flan_u64_to_bytes`
|
||||
all write into one `static char scratch[64]` — "rendered text lives here until the next call", flan_rt.c:184 — and
|
||||
`(string b)` does not copy. So
|
||||
|
||||
```
|
||||
(let [a (string (i64->bytes 11))
|
||||
b (string (i64->bytes 22))]
|
||||
(print a) (print " ") (println b)) ; => 22 22
|
||||
```
|
||||
|
||||
`a` is 11 and prints 22. No crash and no diagnostic. This is not new — the `[u8]` already aliased — but a `string`
|
||||
reads as more value-like and invites exactly this. Format, draw, measure, then format the next one; `digits.flan`
|
||||
sequences itself strictly for this reason. `rl/draw-text` is safe because the shim's `flan_shim_cstr` copies out of
|
||||
ptr+len before the call.
|
||||
|
||||
- **Writing through a string literal is undefined, and the two build modes
|
||||
disagree about how.** `(let [s (bytes "Hi")] (set (at s 0) \h))` stores into
|
||||
a `private unnamed_addr constant`. At `-O0` that is a store to read-only
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user