[email protected] writes:
> (apply format #t "not ok 4 - ~A" X) is a format error because "apply" splices
> its last list argument into the preceding argument list, so you're getting
> (format #t "not ok 4 - ~A" 0 1 2 3).
Of course, I'm sorry. I confused myself trying to pin down the
circumstances that did and didn't fail. Taking that into account
all of the tests outside the function return the correct result,
it appears to be something caused by a C function which returns
s7_values that is called when in a scheme function:
; displays: ok 1 - (0 1 2 3)
(display "ok 1 - ")
(display (list (tl.valfun)))
(newline)
(define (bar)
; displays: not ok 2 - ((0 1 2 3))
(display "not ok 2 - ")
(display (list (tl.valfun)))
(newline)
)
(bar)
This throws "format first argument, (X (list (tl.valfun))), is a
pair". Note that the error message refers to X but comes from the
first format insruction before X gets defined:
(define (foo)
(format #t "not ok 1 - ~A" (list (tl.valfun)))
(newline)
(define X (list (tl.valfun)))
(format #t "not ok 2 - ~A" X)
(newline)
)
(foo)
This segfaults:
(define (foo)
(format #t "not ok 1 - ~A" (list (tl.valfun)))
(newline)
;(define X (list (tl.valfun)))
(format #t "not ok 2 - ~A" X)
(newline)
)
(foo)
As does this:
(define (foo)
(format #t "not ok 1 - ~A" (list (tl.valfun)))
;(newline)
(format #t "not ok 2 - ~A" X)
(newline)
)
(foo)
Curiously this doesn't, instead throwing "format first argument,
("not ok 1 - ~A" (list (tl.valfun))), is a pair":
(define (foo)
(format #t "not ok 1 - ~A" (list (tl.valfun)))
(newline)
(format #t "not ok 2 - ~A" X)
(newline)
)
(foo)
What is commented seems to make no difference, just that there is
a commented-out line between the first format and the second.
I don't actually use the repl, just s7.[ch]. I did have a slightly
hacked-up cload.scm but I don't use it any more.
I'll compile the repl's dependencies and see if I can reproduce it
in there.
In case it makes a difference, the loader I use used to be just a
main function with little more than 'return s7_integer(s7_load(sc,
*argv));' in it but now I load a few C-based extensions first. I
don't think they should be having any effect though. For the most
part they create a few lets with some constants defined by
s7_define_constant_with_environment and functions by
s7_make_typed_function. There are also some functions and macros
defined with s7_eval_c_string_with_environment.
Anyway, as well as the repl I'll make a stripped back loader with
no customisations and see if I can replicate it there as well.
This has nothing to do with my other email about C object values,
which I only implemented an hour ago.
Matthew
_______________________________________________
Cmdist mailing list
[email protected]
https://cm-mail.stanford.edu/mailman/listinfo/cmdist