[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reload-module
From: |
Ludovic Courtès |
Subject: |
Re: reload-module |
Date: |
Fri, 19 Nov 2010 23:38:16 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Hello,
Andy Wingo <address@hidden> writes:
> On Thu 18 Nov 2010 22:45, address@hidden (Ludovic Courtès) writes:
>
>> Hello!
>>
>> "Andy Wingo" <address@hidden> writes:
>>
>>> +(define (reload-module m)
>>> + (let ((f (module-filename m)))
>>> + (if f
>>> + (save-module-excursion
>>> + (lambda ()
>>> + ;; Re-set the initial environment, as in try-module-autoload.
>>> + (set-current-module (make-fresh-user-module))
>>> + (primitive-load-path f)
>>> + m))
>>> + ;; Though we could guess, we *should* know it.
>>> + (error "unknown file name for module" m))))
>>
>> What about adding
>>
>> (module-define-submodule! the-root-module (module-name m)
>> (let ((x (make-module)))
>> (set-module-name! x (module-name m))
>> x))
>>
>> right before the ‘primitive-load-path’ call, such that the module is
>> created anew, instead of being modified incrementally?
>
> That won't work, because it will result in new variables being created
> for any new definitions, so old code that had cached the old variables
> would no longer do what you expect.
Hmm, right; ditto for those that have cached the module itself.
Oh well...
Thanks,
Ludo’.