In lib/_repl.scm:
(define-prim (##make-default-entry-hook) (let ((settings (##vector #f #f))) (lambda (proc args execute) (if (##vector-ref settings 0) (##step-on)) ;; turn on single-stepping (if (##vector-ref settings 1)
(##trace-generate
(##make-call-form proc (##argument-list-remove-absent! args '())
##max-fixnum)
execute
#f)
(execute)))))
how does this code work at all? isn't settings #f #f, which would mean the first if does nothing, and the first part of the second if also does nothing?
is there some funky dynamic-wind / dynamic scope going on here?
Afficher les réponses par date
Urgh ...
(define (setup hook) (let ((settings (##closure-ref hook 1))) (##vector-set! settings 1 #t) (if (##not (##memq proc ##trace-list)) (set! ##trace-list (##cons proc ##trace-list)))))
does ##closure-ref do what I think it does? (break the closure abstraction ... and is the "1" like saying "the first var [which just so happens to be settings]")
this seems awfully hairy + brittle
On Sun, Feb 22, 2009 at 11:33 PM, lowly coder lowlycoder@huoyanjinjing.comwrote:
In lib/_repl.scm:
(define-prim (##make-default-entry-hook) (let ((settings (##vector #f #f))) (lambda (proc args execute) (if (##vector-ref settings 0) (##step-on)) ;; turn on single-stepping (if (##vector-ref settings
(##trace-generate
(##make-call-form
proc (##argument-list-remove-absent! args '())
##max-fixnum)
execute
#f)
(execute)))))
how does this code work at all? isn't settings #f #f, which would mean the first if does nothing, and the first part of the second if also does nothing?
is there some funky dynamic-wind / dynamic scope going on here?
Reminds me of tkl's upvar. There is probably a good reason for this, speed or simply no other way to access it.
On Mon, Feb 23, 2009 at 12:25 AM, lowly coder lowlycoder@huoyanjinjing.com wrote:
Urgh ...
(define (setup hook) (let ((settings (##closure-ref hook 1))) (##vector-set! settings 1 #t) (if (##not (##memq proc ##trace-list)) (set! ##trace-list (##cons proc ##trace-list)))))
does ##closure-ref do what I think it does? (break the closure abstraction ... and is the "1" like saying "the first var [which just so happens to be settings]")
this seems awfully hairy + brittle
On Sun, Feb 22, 2009 at 11:33 PM, lowly coder lowlycoder@huoyanjinjing.com wrote:
In lib/_repl.scm:
(define-prim (##make-default-entry-hook) (let ((settings (##vector #f #f))) (lambda (proc args execute) (if (##vector-ref settings 0) (##step-on)) ;; turn on single-stepping (if (##vector-ref settings
(##trace-generate (##make-call-form proc (##argument-list-remove-absent! args '())
##max-fixnum)
execute
#f) (execute)))))
how does this code work at all? isn't settings #f #f, which would mean the first if does nothing, and the first part of the second if also does nothing?
is there some funky dynamic-wind / dynamic scope going on here?
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
On 23-Feb-09, at 3:25 AM, lowly coder wrote:
Urgh ...
(define (setup hook) (let ((settings (##closure-ref hook 1))) (##vector-set! settings 1 #t) (if (##not (##memq proc ##trace-list)) (set! ##trace-list (##cons proc ##trace-list)))))
does ##closure-ref do what I think it does? (break the closure abstraction ... and is the "1" like saying "the first var [which just so happens to be settings]")
No time to go into the details right now, but yes the compiled closures use a flat representation (a structure with a "code" pointer followed by the free non-global variables of the lambda).
this seems awfully hairy + brittle
Depends. The free variables are sorted (based on their name), so it is possible by a code analysis (and a careful writing of the lambda) to figure out which one is referenced. So it is somewhat brittle for "general use", but for implementing the evaluator itself it is an appropriate abstraction. The evaluator's code would of course gain in clarity if these constants were symbolic... and that should be fixed.
Marc