unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* procedure-source inconsistencies
@ 2008-07-22 16:40 Gregory Marton
  2008-08-08 21:25 ` Neil Jerram
  0 siblings, 1 reply; 3+ messages in thread
From: Gregory Marton @ 2008-07-22 16:40 UTC (permalink / raw)
  To: bug-guile; +Cc: Linda Brown Westrick

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))

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

As a less invasive option, perhaps procedure-source could do whatever it is 
that invocation does to "simplify" the function before returning the source 
for the first time?

Thanks,
Grem

-- 
------ __@   Gregory A. Marton                http://csail.mit.edu/~gremio/
--- _`\<,_                                                                .
-- (*)/ (*)                   There's no place like /home
~~~~~~~~~~~~~~~~-~~~~~~~~_~~~_~~~~~v~~~~^^^^~~~~~--~~~~~~~~~~~~~~~++~~~~~~~





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: procedure-source inconsistencies
  2008-07-22 16:40 procedure-source inconsistencies Gregory Marton
@ 2008-08-08 21:25 ` Neil Jerram
  2008-08-08 21:36   ` Gregory Marton
  0 siblings, 1 reply; 3+ messages in thread
From: Neil Jerram @ 2008-08-08 21:25 UTC (permalink / raw)
  To: Gregory Marton; +Cc: bug-guile, Linda Brown Westrick

2008/7/22 Gregory Marton <gremio@csail.mit.edu>:
> 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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: procedure-source inconsistencies
  2008-08-08 21:25 ` Neil Jerram
@ 2008-08-08 21:36   ` Gregory Marton
  0 siblings, 0 replies; 3+ messages in thread
From: Gregory Marton @ 2008-08-08 21:36 UTC (permalink / raw)
  To: Neil Jerram; +Cc: bug-guile, Linda Brown Westrick

Thank you, Neil!

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

We have to serialize the procedure-qua-association-key to a file between 
when we set the value and when we'll need it next time.


>> 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.

I hadn't even dared hope it would be that easy.  Thank you.

Grem

-- 
------ __@   Gregory A. Marton                http://csail.mit.edu/~gremio/
--- _`\<,_                                                                .
-- (*)/ (*)            #The grappling hooks on to the enemy ship.
~~~~~~~~~~~~~~~~-~~~~~~~~_~~~_~~~~~v~~~~^^^^~~~~~--~~~~~~~~~~~~~~~++~~~~~~~





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-08 21:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-22 16:40 procedure-source inconsistencies Gregory Marton
2008-08-08 21:25 ` Neil Jerram
2008-08-08 21:36   ` Gregory Marton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).