unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* re-using a module
@ 2004-03-30 15:34 Viktor Pavlenko
  2004-03-30 15:50 ` Paul Jarc
  0 siblings, 1 reply; 12+ messages in thread
From: Viktor Pavlenko @ 2004-03-30 15:34 UTC (permalink / raw)


Hi all,

is there a way to reload a module in guile?

Example:

file aaa.scm:
--------------------------------------------->8
(define-module (aaa) #:export (a b))

(define a 3)
(define b (lambda (x) (* x 2)) ;;missing `)'
---------------------------------------------8<

guile> (use-modules (aaa))
ERROR: In procedure list:
ERROR: end of file in ./aaa.scm
ABORT: (misc-error)
guile> (use-modules (aaa))
guile> 

The second use-modules statement does nothing.

(The behavior is exactly the same in the C interface. My program
loads user-defined modules, and if there happens to be a syntax
error in such a module I have to terminate the program. What I would
like to do is tell the user about the error, let her fix it and reload
the module).

Thanks in advance.

Viktor





_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: re-using a module
@ 2004-03-30 17:27 Viktor Pavlenko
  2004-03-30 11:37 ` Issac Trotts
  2004-03-31  5:47 ` Thien-Thi Nguyen
  0 siblings, 2 replies; 12+ messages in thread
From: Viktor Pavlenko @ 2004-03-30 17:27 UTC (permalink / raw)


> From: David Pirotte <david@altosw.be>
> Date: 2004/03/30 Tue AM 11:13:11 EST
> 
> On Tue, 30 Mar 2004 10:50:45 -0500
> prj@po.cwru.edu (Paul Jarc) wrote:
> 
> > Viktor Pavlenko <vvp@rogers.com> wrote:
> > > is there a way to reload a module in guile?
> > 
> > Untested black magic:
> > (use-modules (aaa))
> > (local-remove '(app modules aaa))
> > (use-modules (aaa))
> 

Thanks, that's great. OTOH why isn't it done by default? Shouldn't
guile do a cleanup if it fails to load a module? Besides I'm not too
inclined to use "black magic" in my code...

> once a module has been used, unless you define new
> symbols/functions/methods ... you can simply load the file
> 
> 	(load "xxx.scm")
> 

This (although painful) works great too. Incidentally, I looked for
a C equivalent, and found only scm_primitive_load. Scheme primitive-load
differs from load in that it disregards the module's export list 
(makes all module's symbols visible :-(

Thanks for your help.

Viktor





_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: re-using a module
@ 2004-03-30 18:33 Viktor Pavlenko
  0 siblings, 0 replies; 12+ messages in thread
From: Viktor Pavlenko @ 2004-03-30 18:33 UTC (permalink / raw)
  Cc: guile-user

> From: Issac Trotts <ijtrotts@ucdavis.edu>
> Date: 2004/03/30 Tue AM 06:37:32 EST
> 
> Why not use gh_eval_str("(load \"xxx.scm\"")") ?

Of course, but then what is the C API for? Also, this is a
"do-load-path-yourself" solution.

Am I complaining too much today? ;-)

Viktor





_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

end of thread, other threads:[~2004-04-03  5:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-30 15:34 re-using a module Viktor Pavlenko
2004-03-30 15:50 ` Paul Jarc
2004-03-30 16:13   ` David Pirotte
  -- strict thread matches above, loose matches on Subject: below --
2004-03-30 17:27 Viktor Pavlenko
2004-03-30 11:37 ` Issac Trotts
2004-03-31  5:47 ` Thien-Thi Nguyen
2004-04-01  1:01   ` Viktor Pavlenko
2004-04-01  5:12     ` Thien-Thi Nguyen
2004-04-03  5:17       ` Viktor Pavlenko
2004-04-03  5:38         ` Viktor Pavlenko
2004-04-01  5:21     ` Thien-Thi Nguyen
2004-03-30 18:33 Viktor Pavlenko

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