The valfun function below is defined in a let in the variable *tl*
and import aliases it to tl.valfun. I don't think either of these
matter but it was easier to keep it than modify my tooling to create
the function in the root let.
Same result with s7.c from 2-Sep-2025 and this morning's 2-Oct-2025.
Matthew
tmp/values.scm:
; C function:
;
; static s7_pointer _valfun (s7_scheme *sc, s7_pointer args)
; {
; assert(s7_is_null(sc, args));
; return s7_values(sc, s7_list(sc, 4,
; s7_make_integer(sc, 0),
; s7_make_integer(sc, 1),
; s7_make_integer(sc, 2),
; s7_make_integer(sc, 3)));
; }
(import *tl* "tl.~A" (map car *tl*))
; Outside a function:
; displays: ok 1 - (0 1 2 3)
(display "ok 1 - ")
(display (list (values 0 1 2 3)))
(newline)
; displays: ok 2 - (0 1 2 3)
(display "ok 2 - ")
(display (list (tl.valfun)))
(newline)
; displays: ok 3 - (0 1 2 3)
(format #t "ok 3 - ~A" (list (tl.valfun)))
(newline)
; aborts:
; ;format-error ("format: ~S ~{~S~^ ~}~&~NT^: ~A" "not ok 4 - ~A" (0 1
2 3) 32 "too many arguments")
; ; (apply format #f "not ok 4 - ~A" X)
; ; tmp/values.scm, line 33, position: 867
; (apply format #f "not ok 4 - ~A" X)
;(define X (list (tl.valfun)))
;(apply format #t "not ok 4 - ~A" X)
;(newline)
; Inside a function:
(define (foo)
; displays: ok 5 - (0 1 2 3)
(display "ok 5 - ")
(display (list (values 0 1 2 3)))
(newline)
; displays: not ok 6 - ((0 1 2 3))
(display "not ok 6 - ")
(display (list (tl.valfun)))
(newline)
; aborts, evidently something is jumping ahead to the next instruction:
; ;format first argument, (X (list (tl.valfun))), is a pair but should
be #f, #t, (), or an open output port
; ; ((format #t "not ok 7 - ~A" (list...
; ; tmp/values.scm, line 27, position: 577
; foo: ((format #t "not ok 7 - ~A" (list (tl.v...
; foo: ((newline) (define X (list (tl.valfu...
;(format #t "not ok 7 - ~A" (list (tl.valfun)))
;(newline)
; If I comment out the next (define) leaving format, newline
; or both it segfaults (line numbers will be off by a few
; from the upstream s7.c):
;
; (gdb) bt
; #0 0x0000042b1309db81 in stdout_write_string (sc=0x42d56d0c000,
str=0x42debf05da0 "\001", len=4595278437936, port=0x42d15565d60) at s7.c:30144
; #1 0x0000042b12f46c83 in format_to_port_1 (sc=0x42d56d0c000,
port=0x42d15565d60, str=0x42debf05da0 "\001", args=0x42d155631e0, next_arg=0x0,
with_result=false,
; columnized=false, len=4595278437936, orig_str=0x42debf05e00) at
s7.c:38123
; #2 0x0000042b130e937b in g_format_no_column (sc=0x42d56d0c000,
args=0x42d15563240) at s7.c:38320
; #3 0x0000042b12fa526b in fx_c_aaa (sc=0x42d56d0c000,
arg=0x42debf05fe0) at s7.c:58926
; #4 0x0000042b12ed8ad8 in eval (sc=0x42d56d0c000, first_op=425) at
s7.c:95503
; #5 0x0000042b12eeb52b in s7_load_with_environment (sc=0x42d56d0c000,
filename=0x780e08a0ad08 "tmp/values.scm", let=0x42d15564cb0) at s7.c:32010
; #6 0x0000042b12eedbd9 in s7_load (sc=0x42d56d0c000,
filename=0x780e08a0ad08 "tmp/values.scm") at s7.c:32024
; #7 0x0000042b131578c1 in main (argc=1, argv=0x780e08a0ab40) at
s7run.w:97
; displays: not ok 8 - (values 0 1 2 3)
(define X (list (tl.valfun)))
(apply format #t "not ok 8 - ~A" X)
(newline)
)
(foo)
_______________________________________________
Cmdist mailing list
[email protected]
https://cm-mail.stanford.edu/mailman/listinfo/cmdist