mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 20:00:19 +02:00
* module/language/scheme/translate.scm (trans-pair): In the `set!' case, when a procedure-with-setter is passed, call `trans:pair' with an actual pair. This fixes a long-lasting bug which prevented compilation of `set!' statements with procedures-with-setter (this showed up when compiling `(system vm assemble)'). * module/system/base/compile.scm: Added `objcode->u8vector' to the `#:select' clause. * module/system/base/syntax.scm: Cosmetic changes. * module/system/vm/assemble.scm (preprocess): Removed debugging statements. * src/frames.c: Cosmetic changes. * src/frames.h (SCM_FRAME_SET_DYNAMIC_LINK): New. * src/objcodes.c: Use `scm_t_uint8' instead of `char' when relevant. * src/vm.c (vm_heapify_frames_1): Use `SCM_FRAME_SET_DYNAMIC_LINK ()'. * src/vm_loader.c: Added casts to mute GCC 4 warnings. * testsuite/run-vm-tests.scm (*scheme*): Renamed to `%scheme'. (run-test-from-file): Renamed to `compile/run-test-from-file'. (run-vm-tests): Run each test using both the VM and the interpreter; compare the results. * testsuite/t-proc-with-setter.scm: Try out `get/set'. * doc/Makefile.am (info_TEXINFOS): New. * doc/guile-vm.texi: Added index entries and indices. * doc/texinfo.tex: New file. git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-5
20 lines
644 B
Scheme
20 lines
644 B
Scheme
(define the-struct (vector 1 2))
|
|
|
|
(define get/set
|
|
(make-procedure-with-setter
|
|
(lambda (struct name)
|
|
(case name
|
|
((first) (vector-ref struct 0))
|
|
((second) (vector-ref struct 1))
|
|
(else #f)))
|
|
(lambda (struct name val)
|
|
(case name
|
|
((first) (vector-set! struct 0 val))
|
|
((second) (vector-set! struct 1 val))
|
|
(else #f)))))
|
|
|
|
(and (eq? (vector-ref the-struct 0) (get/set the-struct 'first))
|
|
(eq? (vector-ref the-struct 1) (get/set the-struct 'second))
|
|
(begin
|
|
(set! (get/set the-struct 'second) 77)
|
|
(eq? (vector-ref the-struct 1) (get/set the-struct 'second))))
|