2008/7/22 Gregory Marton <[EMAIL PROTECTED]>:
> Hi folks,
>
> We're running into an issue where we're trying to associate some information
> about functions by associating the info with their serialized form, which is
> in part their procedure-source.  Unfortunately, the procedure-source changes
> when a function is invoked:
>
> (define (equal-source-after-apply? f)
>   (if (not (equal? (procedure-source f)
>                   (begin (f)
>                          (procedure-source f))))
>       (procedure-source f)
>       #t))
>
> (equal-source-after-apply? (lambda () (let ((x 3)) x)))
> ;; before: (lambda () (let ((x 3)) x))
> ;;  after: (lambda () (let* ((x 3)) x))
> (equal-source-after-apply? (lambda () '#:g))
> ;; before: (lambda () (quote #:g))
> ;;  after: (lambda () (begin #:g))

Do you have to use the procedure source as your assoc key?  Why not
use the procedure itself?

> I can imagine one solution to be remembering the actual source somewhere
> instead of regenerating it in procedure-source.  That would be great.

I believe the 'copy read-option does that.  i.e. if you do

(read-enable 'copy)

Guile will store a copy of the original source, and return that as the
result of a (procedure-source ...) call.

Regards,
        Neil


Reply via email to