Re: [PATCH] Fix primitive-eval to return # for definitions

2012-01-30 Thread Andy Wingo
On Mon 30 Jan 2012 00:14, Mark H Weaver  writes:

> What do you think?

Please push, thanks!

Andy
-- 
http://wingolog.org/



Re: [PATCH] Implement scm_call_varargs and scm_call_{7,8,9}

2012-01-30 Thread Andy Wingo
On Mon 30 Jan 2012 02:04, Mark H Weaver  writes:

> Andy suggested that we should add these, so here's a patch to do so.
> Okay to push?

Looks great to me, thanks.  Please push.

Andy
-- 
http://wingolog.org/



Re: [PATCH] Prevent 'error' from being tail-called, for better diagnostics

2012-01-30 Thread Andy Wingo
On Mon 30 Jan 2012 07:39, Mark H Weaver  writes:

> When 'error' is called, the user should _automatically_ be told the
> exact source location where it was called, and the procedure that called
> it should be present in the backtrace.  Therefore, we should somehow
> prevent it from being tail-called.

This is the argument behind R6RS's inclusion of "assert"; see section
11.14.

> One idea is to change 'error' into a macro, and use tricks similar to
> what 'load' does, to cleverly makes it look like a procedure.

Unfortunately this is an incompatible change.  Existing compiled files
which reference the "error" binding expect it to be a procedure, not a
macro.

To provide this source information, a technique like this one might be
applicable: 

  http://funcall.blogspot.com/2009/05/you-knew-id-say-something-part-iv.html

Until we do something to address this issue, we should probably document
this aspect of the behavior of "error".

Andy
-- 
http://wingolog.org/



Re: [PATCH] Implement scm_call_varargs and scm_call_{7,8,9}

2012-01-30 Thread Ludovic Courtès
Andy Wingo  skribis:

> On Mon 30 Jan 2012 02:04, Mark H Weaver  writes:
>
>> Andy suggested that we should add these, so here's a patch to do so.
>> Okay to push?
>
> Looks great to me, thanks.  Please push.

Can we s/scm_call_varargs/scm_call/ instead?  (For consistency with
scm_list_n, it would be ‘scm_call_n’, but that one is already taken for
something else.)

Other than that, OK!

Thanks,
Ludo’.




Re: [PATCH] Implement scm_call_varargs and scm_call_{7,8,9}

2012-01-30 Thread Mark H Weaver
l...@gnu.org (Ludovic Courtès) writes:
> Can we s/scm_call_varargs/scm_call/ instead?  (For consistency with
> scm_list_n, it would be ‘scm_call_n’, but that one is already taken for
> something else.)

Excellent suggestion!  'scm_call' it is :)

Thanks,
  Mark



Re: [PATCH] Prevent 'error' from being tail-called, for better diagnostics

2012-01-30 Thread Mark H Weaver
Andy Wingo  writes:

> On Mon 30 Jan 2012 07:39, Mark H Weaver  writes:
>
>> One idea is to change 'error' into a macro, and use tricks similar to
>> what 'load' does, to cleverly makes it look like a procedure.
>
> Unfortunately this is an incompatible change.  Existing compiled files
> which reference the "error" binding expect it to be a procedure, not a
> macro.

Ah, good point.  Damn.

> To provide this source information, a technique like this one might be
> applicable: 
>
>   http://funcall.blogspot.com/2009/05/you-knew-id-say-something-part-iv.html

Thanks for the pointer, that sounds like a great strategy!

 Mark



Re: add-relative-load-path ? - scm_add_load_path too?

2012-01-30 Thread Ian Hulin
Hi Andy, Ludo,

I've just seen the add-load-path scheme function in the new git
documentation.

Please, please, pretty please can we have a scm_add_load_path API
equivalent callable from C/C++? The LilyPond initialization code
currently does disgusting things like faking
(eval (set! %load-path cons (  %load-path ) ) )

a call such as

(scm_add_load_path (scm_from_locale_string (" Hi all,
> 
> In the following thread:
> 
> http://thread.gmane.org/gmane.lisp.guile.user/8298/focus=8403
> 
> there was a concern that it's difficult to set up the load path
> for simple one-off scripts.
> 
> I had a proposal that we add something like this:
> 
> (define-syntax add-relative-load-path (lambda (x) (syntax-case x
> () ((_ path) (string? (syntax->datum #'path)) (let* ((src
> (syntax-source #'x)) (current-file (or (and src (assq-ref src
> 'filename)) (error "Could not determine current file name"))) 
> (vicinity (dirname (canonicalize-path current-file))) (path-elt
> (in-vicinity vicinity (syntax->datum #'path #`(eval-when
> (compile load eval) (set! %load-path (cons #,path-elt
> %load-path
> 
> Then in your script you would (add-relative-load-path ".").
> 
> Maybe we need an `add-to-load-path' form that handles the
> eval-when, actually, so it would be
> 
> (add-to-load-path (dirname (current-source-filename)))
> 
> or something like that.  (We'd have to define
> current-source-filename as well, in terms of
> current-source-location.)
> 
> What do folks think?  Is it work it?
> 
> Andy




GNU Guile 2.0.4 released

2012-01-30 Thread Ludovic Courtès
We are pleased to announce GNU Guile release 2.0.4, the next maintenance
release for the 2.0.x stable series.

The Guile web page is located at http://gnu.org/software/guile/ .

Guile is an implementation of the Scheme programming language, with
support for many SRFIs, packaged for use in a wide variety of
environments.  In addition to implementing the R5RS Scheme standard and
a large subset of R6RS, Guile includes a module system, full access to
POSIX system calls, networking support, multiple threads, dynamic
linking, a foreign function call interface, and powerful string
processing.

Guile can run interactively, as a script interpreter, and as a Scheme
compiler to VM bytecode suitable for stand-alone applications.  It is
also packaged as a library so that applications can easily incorporate a
complete Scheme interpreter/VM.  An application can use Guile as an
extension language, a clean and powerful configuration language, or as
multi-purpose "glue" to connect primitives provided by the application.

Here are the compressed sources:
  ftp://ftp.gnu.org/gnu/guile/guile-2.0.4.tar.gz   (6.7MB)
  ftp://ftp.gnu.org/gnu/guile/guile-2.0.4.tar.xz   (4.1MB)

Here are the GPG detached signatures[*]:
  ftp://ftp.gnu.org/gnu/guile/guile-2.0.4.tar.gz.sig
  ftp://ftp.gnu.org/gnu/guile/guile-2.0.4.tar.xz.sig

Use a mirror for higher download bandwidth:
  http://www.gnu.org/order/ftp.html

Here are the MD5 and SHA1 checksums:

4129f1d5c20b303d6cb628e790474313  guile-2.0.4.tar.gz
687073b66f1a10dcbbb4c930f7162837  guile-2.0.4.tar.xz
7bffd7564f99bccb6af6950bc7af56af39fc0281  guile-2.0.4.tar.gz
a29a49ea70f87c6211c9885bac543165e31c3a73  guile-2.0.4.tar.xz

[*] Use a .sig file to verify that the corresponding file (without the
.sig suffix) is intact.  First, be sure to download both the .sig file
and the corresponding tarball.  Then, run a command like this:

  gpg --verify guile-2.0.4.tar.gz.sig

If that command fails because you don't have the required public key,
then run this command to import it:

  gpg --keyserver keys.gnupg.net --recv-keys EA52ECF4

and rerun the 'gpg --verify' command.

This release was bootstrapped with the following tools:
  Autoconf 2.68
  Automake 1.11.2
  Libtool 2.4
  Gnulib v0.0-6827-g39c3009

This release provides many bug fixes, performance improvements, and some
new features.  Here are the highlights, taken from the `NEWS' file:

  * Notable changes

  ** Better debuggability for interpreted procedures.

  Guile 2.0 came with a great debugging experience for compiled
  procedures, but the story for interpreted procedures was terrible.  Now,
  at least, interpreted procedures have names, and the `arity' procedure
  property is always correct (or, as correct as it can be, in the presence
  of `case-lambda').

  ** Support for cross-compilation.

  One can now use a native Guile to cross-compile `.go' files for a
  different architecture.  See the documentation for `--target' in the
  "Compilation" section of the manual, for information on how to use the
  cross-compiler.  See the "Cross building Guile" section of the README,
  for more on how to cross-compile Guile itself.

  ** The return of `local-eval'.

  Back by popular demand, `the-environment' and `local-eval' allow the
  user to capture a lexical environment, and then evaluate arbitrary
  expressions in that context.  There is also a new `local-compile'
  command.  See "Local Evaluation" in the manual, for more.  Special
  thanks to Mark Weaver for an initial implementation of this feature.

  ** Fluids can now have default values.

  Fluids are used for dynamic and thread-local binding.  They have always
  inherited their values from the context or thread that created them.
  However, there was a case in which a new thread would enter Guile, and
  the default values of all the fluids would be `#f' for that thread.

  This has now been fixed so that `make-fluid' has an optional default
  value for fluids in unrelated dynamic roots, which defaults to `#f'.

  ** Garbage collector tuning.

  The garbage collector has now been tuned to run more often under some
  circumstances.

  *** Unmanaged allocation

  The new `scm_gc_register_allocation' function will notify the collector
  of unmanaged allocation.  This will cause the collector to run sooner.
  Guile's `scm_malloc', `scm_calloc', and `scm_realloc' unmanaged
  allocators eventually call this function.  This leads to better
  performance under steady-state unmanaged allocation.

  *** Transient allocation

  When the collector runs, it will try to record the total memory
  footprint of a process, if the platform supports this information.  If
  the memory footprint is growing, the collector will run more frequently.
  This reduces the increase of the resident size of a process in response
  to a transient increase in allocation.

  *** Management of threads, bignums

  Creating a thread will allocate a fair amount of memory.  Guile now does
  some GC work (using `GC_collect_a_littl

Re: GNU Guile 2.0.4 released

2012-01-30 Thread Ludovic Courtès
... and I forgot to bump the SONAME.  :-/

I guess I have to push a 2.0.5 tarball now?  Thoughts?

Ludo’.




Re: GNU Guile 2.0.4 released

2012-01-30 Thread Neil Jerram
l...@gnu.org (Ludovic Courtès) writes:

> ... and I forgot to bump the SONAME.  :-/
>
> I guess I have to push a 2.0.5 tarball now?  Thoughts?

I'm afraid I've forgotten the implications of that...

But congratulations and thanks for the release anyway; for my FFI
hacking I particularly appreciate the fixes related to
procedure->pointer and GC.

   Neil



[PATCH] Doc: protecting procedure->pointer pointers from GC

2012-01-30 Thread Neil Jerram
Following debugging of a strange issue where oFono appeared to be
sending a D-Bus signal from the wrong object, but I eventually realised
that the problem was in my own code...

Neil

>From 02d80ad14c3bb8f89d7ba807dac658be6dd06df1 Mon Sep 17 00:00:00 2001
From: Neil Jerram 
Date: Mon, 30 Jan 2012 21:12:37 +
Subject: [PATCH] Doc: protecting procedure->pointer pointers from GC

* doc/ref/api-foreign.texi (Dynamic FFI): New text covering when pointers
  need to be retained.
---
 doc/ref/api-foreign.texi |   33 +
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi
index 6ece7f8..19d6b29 100644
--- a/doc/ref/api-foreign.texi
+++ b/doc/ref/api-foreign.texi
@@ -961,6 +961,39 @@ function can be made accessible to Scheme (@pxref{Array Sort Function,
 
 And voil@`a!
 
+If you use @code{procedure->pointer} to pass a Scheme procedure as a
+callback for a C library to invoke asynchronously later --- for example,
+as a handler for a D-Bus signal --- you must somehow keep a reference to
+the pointer that @code{procedure->pointer} returns, for as long as the C
+library might invoke the callback.  Otherwise the pointer can be
+prematurely garbage collected, leading to unsafe and arbitrary behaviour
+if the now-invalid callback is called.
+
+This example, which registers a Scheme procedure as a handler for a
+GObject signal, uses @code{make-object-property} to do that:
+
+@example
+(define gobject-signal-handlers (make-object-property))
+
+(define (gobject-connect object signal proc)
+  (let ((ptr (procedure->pointer void
+ (lambda (...C callback args...)
+   (proc ...Scheme args...))
+ (list ...C callback types...
+;; Protect the pointer from being prematurely collected.
+(set! (gobject-signal-handlers object)
+  (acons signal
+ ptr
+ (or (gobject-signal-handlers object) '(
+;; Register the handler.
+(g_signal_connect_data object
+   (string->pointer signal)
+   ptr
+   %null-pointer
+   %null-pointer
+   0)))
+@end example
+ 
 Note that @code{procedure->pointer} is not supported (and not defined)
 on a few exotic architectures.  Thus, user code may need to check
 @code{(defined? 'procedure->pointer)}.  Nevertheless, it is available on
-- 
1.7.8.3



Re: GNU Guile 2.0.4 released

2012-01-30 Thread Hans Aberg

On 30 Jan 2012, at 22:13, Ludovic Courtès wrote:

> ... and I forgot to bump the SONAME.  :-/
> 
> I guess I have to push a 2.0.5 tarball now?  Thoughts?

Are you sure it was there in earlier versions? Though OS X uses different 
objective file format, I could not find it in the .dylib.

Hans





GNU Guile 2.0.5 released

2012-01-30 Thread Ludovic Courtès
We are pleased to announce GNU Guile release 2.0.5.  This release fixes
the binary interface information (SONAME) of libguile, which was
incorrect in 2.0.4.  It does not contain other changes.

Please be sure to upgrade to 2.0.5 if you already installed 2.0.4.
We apologize for the inconvenience.


The Guile web page is located at http://gnu.org/software/guile/ .

Guile is an implementation of the Scheme programming language, with
support for many SRFIs, packaged for use in a wide variety of
environments.  In addition to implementing the R5RS Scheme standard and
a large subset of R6RS, Guile includes a module system, full access to
POSIX system calls, networking support, multiple threads, dynamic
linking, a foreign function call interface, and powerful string
processing.

Guile can run interactively, as a script interpreter, and as a Scheme
compiler to VM bytecode suitable for stand-alone applications.  It is
also packaged as a library so that applications can easily incorporate a
complete Scheme interpreter/VM.  An application can use Guile as an
extension language, a clean and powerful configuration language, or as
multi-purpose "glue" to connect primitives provided by the application.

Here are the compressed sources:
  ftp://ftp.gnu.org/gnu/guile/guile-2.0.5.tar.gz   (6.7MB)
  ftp://ftp.gnu.org/gnu/guile/guile-2.0.5.tar.xz   (4.1MB)

Here are the GPG detached signatures[*]:
  ftp://ftp.gnu.org/gnu/guile/guile-2.0.5.tar.gz.sig
  ftp://ftp.gnu.org/gnu/guile/guile-2.0.5.tar.xz.sig

Use a mirror for higher download bandwidth:
  http://www.gnu.org/order/ftp.html

Here are the MD5 and SHA1 checksums:

bcf70d54b44c99cb9acd3f63c5486b4b  guile-2.0.5.tar.gz
81110e16dcdb24c825fecc41b214edb9  guile-2.0.5.tar.xz
0cf94962ab637975bf2ad00afa15638dcc67408f  guile-2.0.5.tar.gz
e97a332228a17c4af60453280e2596cec55be007  guile-2.0.5.tar.xz

[*] Use a .sig file to verify that the corresponding file (without the
.sig suffix) is intact.  First, be sure to download both the .sig file
and the corresponding tarball.  Then, run a command like this:

  gpg --verify guile-2.0.5.tar.gz.sig

If that command fails because you don't have the required public key,
then run this command to import it:

  gpg --keyserver keys.gnupg.net --recv-keys EA52ECF4

and rerun the 'gpg --verify' command.

This release was bootstrapped with the following tools:
  Autoconf 2.68
  Automake 1.11.2
  Libtool 2.4
  Gnulib v0.0-6827-g39c3009

You can follow Guile development in the Git repository and on the Guile
mailing lists.  Guile builds from the `master' branch of Git have
version number 2.1.x.

Guile versions with an odd middle number, e.g., 2.1.*, are unstable
development versions.  Even middle numbers indicate stable versions.
This has been the case since the 1.3.* series.

Please report bugs to `bug-gu...@gnu.org'.  We also welcome reports of
successful builds, which can be sent to `guile-devel@gnu.org'.

Ludovic, on behalf of the Guile team.


pgpAKIBWMLN8w.pgp
Description: PGP signature


Re: GNU Guile 2.0.4 released

2012-01-30 Thread Ludovic Courtès
All apologies.   This should be fixed now with 2.0.5.

And note that this significantly increases our average release rate,
which is excellent for publicity, no?

Ludo’.




Re: GNU Guile 2.0.5 released

2012-01-30 Thread Bruce Korb

On 01/30/12 14:02, Ludovic Courtès wrote:

We are pleased to announce GNU Guile release 2.0.5.


And we users are pleased to have it.  Thank you!!

Regards, Bruce