ocaml: phase 2+6 print primitives wire to host display (+2 tests, 444 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 46s

print_string / print_endline / print_int / print_newline now route to
SX display primitive (not the non-existent print/println). print_endline
appends '\n'.

let _ = expr ;; at top level confirmed working via the
wildcard-param parser.
This commit is contained in:
2026-05-08 17:37:00 +00:00
parent cabf5dc9c3
commit 0bc6dbd233
3 changed files with 22 additions and 4 deletions

View File

@@ -72,10 +72,11 @@
(list "_string_of_float" (fn (f) (str f)))
(list "_char_code" (fn (c) (char-code c)))
(list "_char_chr" (fn (n) (char-from-code n)))
;; Print: prints to host stdout via println.
(list "print_string" (fn (s) (begin (print s) nil)))
(list "print_endline" (fn (s) (begin (println s) nil)))
(list "print_int" (fn (i) (begin (print (str i)) nil)))
;; Print: route to host SX `display` (no automatic newline).
(list "print_string" (fn (s) (begin (display s) nil)))
(list "print_endline" (fn (s) (begin (display s) (display "\n") nil)))
(list "print_int" (fn (i) (begin (display (str i)) nil)))
(list "print_newline" (fn (_) (begin (display "\n") nil)))
;; Float math primitives.
(list "_float_sqrt" (fn (x) (sqrt x)))
(list "_float_sin" (fn (x) (sin x)))