Re: ice-9 and $GUILE_LOAD_PATH

2008-01-30 Thread Dave Pawson

Thanks for the reply Mike.

Mike Gran wrote:

If I recall correctly, the breakpoint library was split off into a separate 
package.  The manual is incorrect.  This is a known bug, and should be fixed in 
the next release.





The separate package lives here, I think.

https://gna.org/projects/guile-debugging


from which
; ** GDS setup

;; The first thing to do, if you haven't already, is to load the GDS
;; library into Emacs.  The Emacs Lisp expression for this is:
(require 'gds)

elisp?

And the documentation link http://www.ossau.uklinux.net/guile-debugging
is 404.
Bug reported, but one from 2005 is still not assigned.

http://download.gna.org/guile-debugging/guile-debugging.html
seems good though.

I'm assuming it needs to be dropped within the same 'ice-9' area
to be picked up by the environmental variable.


regards

--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk




Re: ice-9 and $GUILE_LOAD_PATH

2008-01-30 Thread Neil Jerram
Dave Pawson <[EMAIL PROTECTED]> writes:

> Thanks for the reply Mike.
>
> Mike Gran wrote:
>> If I recall correctly, the breakpoint library was split off into a
>> separate package.  The manual is incorrect.  This is a known bug,
>> and should be fixed in the next release.

Yes, indeed, sorry about that.  The incorrect doc was in 1.8.1 through
1.8.3, but has been removed now from 1.8.x CVS, so will no longer be
misleading people in 1.8.4.

>
>> The separate package lives here, I think.
>>
>> https://gna.org/projects/guile-debugging
>
> from which
> ; ** GDS setup
>
> ;; The first thing to do, if you haven't already, is to load the GDS
> ;; library into Emacs.  The Emacs Lisp expression for this is:
> (require 'gds)
>
> elisp?

Yes.  guile-debugging is a slight misnomer, because it actually
provides (or tries to) two overlapping things:

- Scheme-accessible breakpoints (and traps, and other bits of Scheme
  infrastructure)

- modes, keystrokes etc. for using Guile conveniently from within
  Emacs.

The two things overlap, because one of the nicest bits (IMHO :-)) is
how Emacs displays the Scheme stack when stopped at a breakpoint, and
allows easy navigation of it.

> And the documentation link http://www.ossau.uklinux.net/guile-debugging
> is 404.

I'm sorry, I've put something up now at
http://www.ossau.uklinux.net/guile-debugging that hopefully makes
sense, and links to the correct doc.

> Bug reported, but one from 2005 is still not assigned.

Thanks for raising your bug.  The others aren't assigned because I'm
(so far) the only developer, so there isn't much point.

> http://download.gna.org/guile-debugging/guile-debugging.html
> seems good though.

It has most of the right memes, but a lot of the details have moved
on.

> I'm assuming it needs to be dropped within the same 'ice-9' area
> to be picked up by the environmental variable.

guile-debugging could be installed anywhere, so long as you add the
install location to your GUILE_LOAD_PATH.  In practice, it's most
convenient to install it somewhere that's already in the standard
GUILE_LOAD_PATH, i.e. /usr/local/share/guile/site or
/usr/share/guile/site (depending on the prefix that Guile was
built).

> regards
>
> -- 
> Dave Pawson
> XSLT XSL-FO FAQ.
> http://www.dpawson.co.uk

Thanks for your interest.  Please do let me know how you find it, once
you get past these initial troubles.

Regards,
Neil





Re: threading issue in 1.8.3

2008-01-30 Thread Neil Jerram
Neil Jerram <[EMAIL PROTECTED]> writes:

> Antoine Mathys <[EMAIL PROTECTED]> writes:
>
>> Hello,
>>
>> I am having a problem with threads in 1.8.3 .
>
>> It seems that for some reason you cannot load modules from a different thread
>> than the one which first initialized guile.
>>
>> Any idea how to get this to work ?
>
> Apologies for the delay in responding...
>
> I think this is caused by the second thread not knowing what its
> current module is.  Can you try adding, before the scm_shell() call:
>
>   scm_set_current_module (scm_lookup_closure_module (SCM_BOOL_F));
>
> and report if that helps?

This problem was a bit more complex than it looked.

scm_shell () with no command line args expands to

  (begin (turn-on-debugging) (load-user-init) (top-repl))

And (top-repl) calls (set-current-module guile-user-module) very early
on, which means that any `use-modules' calls after that will be fine.

Therefore, the reported call stack (which indicates a problem in a
`use-modules' call, because of (current-module) being #f) can only be
caused by a `use-modules' call during the (load-user-init) - i.e. when
loading ~/.guile.

(To confirm this: my ~/.guile had a `use-syntax' call in it (which is
mostly equivalent to `use-modules'), and I got the same stack as you;
when I commented that out, I didn't see the reported stack any more.)

Anyway, code in ~/.guile should expect (current-module) to be sane, so
the necessary fix is still to make sure that (current-module) always
returns a module (so long as the module system has booted).  My
proposed patch for this is attached.

Two other notes for the record.

1. In my tests, the test program hung after the second thread had
   begun (top-repl), before trying to read any input from stdin.  This
   was because the second thread decided to GC, and so tried to put
   the first thread to sleep.  Put the first thread was blocked inside
   pthread_join ().  The fix for this is for the test program to do
   the pthread_join () inside a scm_without_guile () call, as in the
   attached patch.

2. If the second thread had been started in Scheme, it would have
   inherited the first thread's value of (current-module), which was
   already non-#f (as a result of the (define-module ...) call at the
   end of boot-9.sc,).  So this problem only occurs with multiple
   threads started in C using scm_with_guile ().

Regards,
Neil

Index: libguile/modules.c
===
RCS file: /cvsroot/guile/guile/guile-core/libguile/modules.c,v
retrieving revision 1.62.2.1
diff -u -r1.62.2.1 modules.c
--- libguile/modules.c	12 Feb 2006 13:42:51 -	1.62.2.1
+++ libguile/modules.c	30 Jan 2008 23:39:10 -
@@ -40,12 +40,25 @@
 
 static SCM the_module;
 
+static SCM the_root_module_var;
+
+static SCM
+the_root_module ()
+{
+  if (scm_module_system_booted_p)
+return SCM_VARIABLE_REF (the_root_module_var);
+  else
+return SCM_BOOL_F;
+}
+
 SCM_DEFINE (scm_current_module, "current-module", 0, 0, 0,
 	(),
 	"Return the current module.")
 #define FUNC_NAME s_scm_current_module
 {
-  return scm_fluid_ref (the_module);
+  SCM curr = scm_fluid_ref (the_module);
+
+  return scm_is_true (curr) ? curr : the_root_module ();
 }
 #undef FUNC_NAME
 
@@ -234,17 +247,6 @@
 
 SCM_SYMBOL (sym_module, "module");
 
-static SCM the_root_module_var;
-
-static SCM
-the_root_module ()
-{
-  if (scm_module_system_booted_p)
-return SCM_VARIABLE_REF (the_root_module_var);
-  else
-return SCM_BOOL_F;
-}
-
 SCM
 scm_lookup_closure_module (SCM proc)
 {
Index: test-suite/standalone/Makefile.am
===
RCS file: /cvsroot/guile/guile/guile-core/test-suite/standalone/Makefile.am,v
retrieving revision 1.13.2.6
diff -u -r1.13.2.6 Makefile.am
--- test-suite/standalone/Makefile.am	29 Dec 2007 01:34:18 -	1.13.2.6
+++ test-suite/standalone/Makefile.am	30 Jan 2008 23:39:10 -
@@ -110,6 +110,12 @@
 check_SCRIPTS += test-use-srfi
 TESTS += test-use-srfi
 
+# test-with-guile-module
+test_with_guile_module_CFLAGS = ${test_cflags}
+test_with_guile_module_LDADD = ${top_builddir}/libguile/libguile.la
+check_PROGRAMS += test-with-guile-module
+TESTS += test-with-guile-module
+
 all-local:
 	cd ${srcdir} && chmod u+x ${check_SCRIPTS}
 
Index: test-suite/standalone/test-with-guile-module.c
===
RCS file: test-suite/standalone/test-with-guile-module.c
diff -N test-suite/standalone/test-with-guile-module.c
--- /dev/null	1 Jan 1970 00:00:00 -
+++ test-suite/standalone/test-with-guile-module.c	30 Jan 2008 23:39:10 -
@@ -0,0 +1,52 @@
+#include 
+#include 
+
+void * thread_inner_main (void * unused);
+void * thread_main (void * unused);
+void * do_join (void * data);
+void * inner_main (void * unused);
+
+void * thread_inner_main (void * unused)
+{
+  int argc = 3;
+  char* argv[] = { "guile",
+		   "-c",
+		   "(or (current-module) 

Re: threading issue in 1.8.3

2008-01-30 Thread Antoine Mathys

> scm_join_thread ?
>   
Yes. I missed it because it is not in the manual.





  
_ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
http://mail.yahoo.fr




Re: threading issue in 1.8.3

2008-01-30 Thread Antoine Mathys

> My proposed patch for this is attached.
>   
Thanks, works great.





  
_ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
http://mail.yahoo.fr