bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: procedure-source inconsistencies


From: Neil Jerram
Subject: Re: procedure-source inconsistencies
Date: Fri, 8 Aug 2008 22:25:18 +0100

2008/7/22 Gregory Marton <address@hidden>:
> 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

[Prev in Thread] Current Thread [Next in Thread]