On Sep 11, 2009, at 3:22 AM, Eduardo Cavazos wrote:

Hi Aziz,

(library (a)
 (export a)
 (import (rnrs))
 (define (a) (x))
 (define (x) 10))

(library (b)
 (export b)
 (import (rnrs)
         (a))
 (define (b) (a)))

Suppose I've imported both of these into the repl. And let's say I've
started a thread which is printing the result of (b), once per second (I
know... Ikarus doesn't have threads, but for example).

Now say I want to change 'x' so that it returns 20, and have the
currently running thread reflect this change.

It seems non of the above suggestions (set!, set-car!, etc.) won't work in this case.

It seems that you want me to do some work for you. :-)

I can easily write

(library (a)
 (export a)
 (import (rnrs-dev))
 (define (a) (x))
 (define (x) 10))

(library (b)
 (export b)
 (import (rnrs-dev)
         (a))
 (define (b) (a)))

and then, from the repl, do

> (import (a) (b))
> (set! a (lambda () 20))
> (b)
17

If you could get into the internal environment of library (a) then
perhaps set! would work. I.e. (set! x (lambda () 20)).

*You* can make it work.  *I* don't need to do anything to make it work.

What about 'uninstall-library'? My understanding is that even if you
uninstall library a and library b, and reimport them the thread won't be
affected.

Right.  Uninstalling makes the libraries "dangle", not disappear.  What
you want is to whack the variables with new values.  You can already do
that, no?

Sure, I know that I could restructure make 'x' an exported parameter.

You won't need to do that.

Ideally, I'd edit 'a.sls' in Geiser, hit some keystroke which means
"reload library" and the running thread (no cheating by restarting the
thread) starts to reflect the change.

[Side question.

Suppose in some library, you have

(define (x) 12)

and in the repl, you have:

(define str (format "~s" (make-vector (x) #t)))

Suppose now that you change the 12 to 13.  Do you expect str to now
have 3 extra characters?]

Anyways, I know this isn't your style. But it is what some developers
want. Please consider accomadating them. :-)

I just did.  :-)  Now it's up to you to just implement (rnrs-dev).
(while you're at it, you can also make it start a repl in the library
environment on demand too.)

Aziz,,,

Reply via email to