From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: reload-module
Date: Fri, 19 Nov 2010 23:38:16 +0100 [thread overview]
Message-ID: <87oc9lvt0n.fsf@gnu.org> (raw)
In-Reply-To: m3pqu12u77.fsf@unquote.localdomain
Hello,
Andy Wingo <wingo@pobox.com> writes:
> On Thu 18 Nov 2010 22:45, ludo@gnu.org (Ludovic Courtès) writes:
>
>> Hello!
>>
>> "Andy Wingo" <wingo@pobox.com> 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’.
prev parent reply other threads:[~2010-11-19 22:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1821146050.900955.1290113203703.JavaMail.root@zmbs1.inria.fr>
2010-11-18 21:45 ` reload-module Ludovic Courtès
2010-11-19 15:45 ` reload-module Andy Wingo
2010-11-19 22:38 ` Ludovic Courtès [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oc9lvt0n.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).