summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-08-06 23:02:44 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-08-06 23:02:44 -0700
commitfbcdc0c91be3700391a3f0294f87c26f2781944d (patch)
tree02b996878ed190aab5e45a7f78c3e385e170b055 /stdlib
parent981ce2a177aac10f7999cc329c5aefdae853daef (diff)
downloadtxr-fbcdc0c91be3700391a3f0294f87c26f2781944d.tar.gz
txr-fbcdc0c91be3700391a3f0294f87c26f2781944d.tar.bz2
txr-fbcdc0c91be3700391a3f0294f87c26f2781944d.zip
compiler: bug: ensure numbers externalized sanely.
* stdlib/compiler.tl (dump-to-tlo): To ensure numbers are externalized in such a way that they will be loaded back exactly, we need to set a few special variables. For integers, we want *print-base* to be 10. Numbers printed in other bases cannot be read back correctly. Octal, hex and binary could be, but they would need to be printed with the correct prefixes. For floating-point values, we want to switch to the default print format, and use flo-max-dig for the precision. That one s not not the default value; the default is flo-dig.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/compiler.tl3
1 files changed, 3 insertions, 0 deletions
diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl
index 423403e7..58685741 100644
--- a/stdlib/compiler.tl
+++ b/stdlib/compiler.tl
@@ -2499,6 +2499,9 @@
(defun dump-to-tlo (out-stream out)
(let* ((*print-circle* t)
+ (*print-base* 10)
+ (*print-flo-format* "~s")
+ (*print-flo-precision* flo-max-dig)
(*package* (sys:make-anon-package))
(out-forms (partition* out.(get) (op where (op eq :fence)))))
(prinl %tlo-ver% out-stream)