Join Nostr
2025-04-30 09:32:01 UTC
in reply to

Ramin Honary on Nostr: nprofile1q…ejrff But you ask a good question, I wonder how one could introspect ...

But you ask a good question, I wonder how one could introspect properties of procedures and change their names. The procedure in memory might store a reference to an interned symbol. I tried a few things in the REPL:

(define f (lambda () 'hey))
;; -> f
$33 = #<procedure f ()>
;; -> (define g f)
;; -> f
$34 = #<procedure f ()>
;; -> g
$35 = #<procedure f ()>
;; -> (let ((a (lambda () 'bye))) (set! f a) a)
$36 = #<procedure a ()>
;; -> f
$37 = #<procedure a ()>
;; -> g
$38 = #<procedure f ()>

So now the REPL thinks f is called a. And I discovered that you can change the name of a procedure in Guile like this:

(set! f (lambda args (apply f args)))
f
;; -> $40 = #<procedure f args>