mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
Fixes the mutually-recursive toplevel definitions case. This could be fixed by rewriting bodies as letrecs, as r6 does, but that's not really repl-compatible. * module/system/il/ghil.scm (ghil-lookup): Ok, if we can't locate a variable, mark it as unresolved. * module/system/il/compile.scm (make-glil-var): Compile unresolved variables as <glil-late-bound> objects. * module/system/il/glil.scm: Add <glil-late-bound> definition. * module/system/vm/assemble.scm (codegen): And, finally, when we see a <vlate-bound> object, allocate a slot for it in the object vector, setting it to a symbol. Add a new pair of instructions to resolve that symbol to a variable at the last minute. * src/vm_loader.c (load-number): Bugfix: the radix argument should be SCM_UNDEFINED in order to default to 10. (late-bind): Add an unresolved symbol to the object vector. Could be replaced with load-symbol I guess. * src/vm_system.c (late-variable-ref, late-variable-set): New instructions to do late symbol binding. * testsuite/Makefile.am (vm_test_files): * testsuite/t-mutual-toplevel-defines.scm: New test, failing for some reason involving the core even? and odd? definitions.
8 lines
116 B
Scheme
8 lines
116 B
Scheme
(define (even? x)
|
|
(or (zero? x)
|
|
(not (odd? (1- x)))))
|
|
|
|
(define (odd? x)
|
|
(not (even? (1- x))))
|
|
|
|
(even? 20)
|