Re: A Guile debugger workgroup?

2023-03-03 Thread Jan Nieuwenhuizen
Janneke Nieuwenhuizen writes:

Fixing typos in peek-error.

>From bf0f03090d73ea87f1be772010d6209b4372e78b Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" 
Date: Fri, 3 Mar 2023 11:26:34 +0100
Subject: [PATCH] Add peek-error, pke.

Debuging using `pk' is popular in Guile, but not really usable if your
program is as (pseudo-)filter, i.e., writing its output to stdout.

* module/ice-9/boot-9.scm (peek-error, pke): New procedures.
---
 module/ice-9/boot-9.scm | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index dc3537063..4868f6f3c 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -183,6 +183,16 @@ This is handy for tracing function calls, e.g.:
 
 (define pk peek)
 
+(define (peek-error . stuff)
+  "Like PEEK (PK), writing to (CURRENT-ERROR-PORT)."
+  (newline (current-error-port))
+  (display ";;; " (current-error-port))
+  (write stuff (current-error-port))
+  (newline (current-error-port))
+  (car (last-pair stuff)))
+
+(define pke peek-error)
+
 (define (warn . stuff)
   (newline (current-warning-port))
   (display ";;; WARNING " (current-warning-port))
-- 
2.39.1


-- 
Janneke Nieuwenhuizen   | GNU LilyPond https://LilyPond.org
Freelance IT https://www.JoyOfSource.com | Avatar® https://AvatarAcademy.com


Re: [PATCH 0/3] Add '-Wunused-module'

2023-02-12 Thread Jan Nieuwenhuizen
Ludovic Courtès writes:

Hello,

> The new ‘-Wunused-module’ warning is enabled at ‘-W2’ only.  The main
> reason for not enabling it at ‘-W1’ is that in the case of modules used
> at macro-expansion time only, such as (srfi srfi-26), it cannot
> determine whether a module is definitely unused.  In this case, the
> compiler reports the module as “possibly unused”, and it is up to the
> programmer to check that claim.
[..]
> Thoughts?

The `possibly undefined' warnings about the srfi-9 gnu, srfi-26 and
curried-definition modules are a bit unfortunate, but easy to check.
It allowed me to trim quite some imports in Dezyne modules.
Very nice!

It seems that only re-exporting a (non-macro) variable from an otherwise
un used module gives a false positive `unused module' warning; it
doesn't even say `possibly unused module'.  Not a big problem, but can
anything be done about that?

Greetings,
Janneke

$ git diff --stat
 dzn/ast.scm   |  3 ---
 dzn/ast/display.scm   |  3 +--
 dzn/ast/equal.scm |  5 +
 dzn/ast/goops.scm |  1 -
 dzn/ast/lookup.scm|  1 -
 dzn/ast/normalize.scm | 17 -
 dzn/ast/parse.scm |  4 
 dzn/ast/wfc.scm   |  1 -
 dzn/code.scm  |  7 ---
 dzn/code/c++.scm  |  6 --
 dzn/code/dot.scm  |  4 +---
 dzn/code/dzn.scm  |  7 ---
 dzn/code/json.scm |  4 +---
 dzn/code/makreel.scm  |  6 +-
 dzn/commands/code.scm |  3 +--
 dzn/commands/graph.scm|  3 +--
 dzn/commands/lts.scm  |  4 +---
 dzn/commands/parse.scm|  4 
 dzn/commands/simulate.scm |  3 +--
 dzn/commands/traces.scm   |  4 +---
 dzn/commands/verify.scm   |  5 +
 dzn/explore.scm   |  4 
 dzn/indent.scm|  8 +---
 dzn/lts.scm   |  3 +--
 dzn/parse/peg.scm |  5 +
 dzn/peg.scm   |  3 +--
 dzn/script.scm|  4 +---
 dzn/simulate.scm  |  2 --
 dzn/templates.scm |  4 +---
 dzn/verify/constraint.scm |  4 +---
 dzn/verify/pipeline.scm   |  2 --
 dzn/vm/compliance.scm |  1 -
 dzn/vm/evaluate.scm   |  3 +--
 dzn/vm/report.scm |  1 -
 dzn/vm/run.scm|  4 +---
 dzn/vm/step.scm   |  2 --
 dzn/vm/util.scm   |  4 +---
 test/dzn/dzn.scm  |  6 +++---
 test/dzn/language.scm | 11 ++-
 test/dzn/normalize.scm|  5 ++---
 test/dzn/silence.scm  |  3 +--
 41 files changed, 41 insertions(+), 133 deletions(-)

-- 
Janneke Nieuwenhuizen   | GNU LilyPond https://LilyPond.org
Freelance IT https://www.JoyOfSource.com | Avatar® https://AvatarAcademy.com



Re: GNU Guile 3.0.9rc1 available for testing!

2023-01-21 Thread Jan Nieuwenhuizen
Thompson, David writes:

Hello!

> On Fri, Jan 20, 2023 at 10:58 AM Ludovic Courtès  wrote:
>>
>> Please report any issues you may find.  I’m particularly interested in
>> portability regressions (NetBSD and other BSDs, macOS, MinGW, as well as
>> architectures other than x86_64).
>
> I was curious about the MinGW build, so I used a Guix command you
> shared to build it:
>
> guix build guile-next --with-git-url=guile-next=$HOME/Code/guile
> --with-branch=guile-next=main --target=x86_64-w64-mingw32

I've tried twice, but the build didn't finish -- too long silence
time somewhere?  Last time it got to

...
wrote `scripts/generate-autoload.go'
  BOOTSTRAP(stage0) GUILEC scripts/help.go
wrote `scripts/help.go'
  BOOTSTRAP(stage0) GUILEC scripts/lint.go

where it hangs, the build server showing nothing no guix-build-* in
/tmp, and a rebuild doesn't fetch the built package.  So yeah, dunno.

> I then copied the resulting /gnu/store directory somewhere writable,
> copied over all the DLLs (libgc, libunistring, etc.) it needed from
> /gnu/store into the 'bin' directory, and tried running with wine64 but
> it failed:

Yeah, I've been using something like

WINEPATH=$(guix shell wine64 -- winepath -w 
\
$(echo $(guix gc -R 
\
  $(GUIX_PACKAGE_PATH=guix guix build   
\
 --target=x86_64-w64-mingw32 guile-mingw))) 
\
   | sed 's,$,/bin,g' | tr '\n' ';')
\
guix shell wine64 -- wine   
\
$(GUIX_PACKAGE_PATH=guix guix build --target=x86_64-w64-mingw32 
\
   guile-mingw)/bin/guile.exe   
\
-c '(format #t "Hello  ~a world!\n" %host-type)'

that's on the wip-mingw branch that has a guile-mingw package in a
guix/

> $ guix shell wine64 -- wine64 guile.exe
[..]
> Mingw-w64 runtime failure:
> 32 bit pseudo relocation at 000140001568 out of range, targeting
> 000319370E80, yielding the value 0001D936F914.
>
> abnormal program termination
> ```

Yeah, you need at least

76950b428 Support for x86_64-w64-mingw32.

or something similar, or another approach for addressing the
SIZEOF_LONG==4 issue on MinGW.  And compile with --disable-jit, AFAIK
nobody got that to work just yet.

> Thanks for all the hard work on the release!

+1

Greetings,
Janneke

-- 
Jan Nieuwenhuizen   | GNU LilyPond https://lilypond.org
Freelance IT https://JoyOfSource.com | Avatar® https://AvatarAcademy.com



Re: wip-mingw with x86_64 support updated for 3.0.8

2022-05-16 Thread Jan Nieuwenhuizen
Jan Nieuwenhuizen writes:

Hello again,

> I've reset and updated wip-mingw onto latest main:
>
> https://git.savannah.gnu.org/cgit/guile.git/log/?h=wip-mingw

If you tried this with a recent Guix, you probably got a segfault.  I
finally found that compiling with -flto (--enable-lto) creates broken
DLLs with binutils > 2.35.2.  This is "fixed" by using --disable-lto
when compiling for mingw.

So, also with a recent Guix, this should work:

WINEPATH=$(guix shell wine64 -- winepath -w\
   $(echo $(guix gc -R \
 $(GUIX_PACKAGE_PATH=guix guix build   \
--target=x86_64-w64-mingw32 guile-mingw))) \
  | sed 's,$,/bin,g' | tr '\n' ';')\
   guix shell wine64 -- wine   \
   $(GUIX_PACKAGE_PATH=guix guix build --target=x86_64-w64-mingw32 \
  guile-mingw)/bin/guile.exe   \
   -c '(format #t "Hello ~a world!\n" %host-type)'

Greetings,
Janneke

-- 
Jan Nieuwenhuizen   | GNU LilyPond https://lilypond.org
Freelance IT https://JoyOfSource.com | Avatar® https://AvatarAcademy.com



wip-mingw with x86_64 support updated for 3.0.8

2022-05-11 Thread Jan Nieuwenhuizen
Hi!

I've reset and updated wip-mingw onto latest main:

https://git.savannah.gnu.org/cgit/guile.git/log/?h=wip-mingw

Most changes are simply a continuation of the previous
x86_64-w64-mingw32 work done for 3.0.7, using intptr_t and uintptr_t
instead of scm_t_inum or long and unsigned long.

There's one new problem though, the fix I made to determine
file-name-convention correctly when (cross)compiling and when running
now does not work anymore.

FIXME in 3.0.7, this works:

  ;; boot-9.scm
  (define (compile-time-file-name-convention)
(let ((target ((@ (system base target) target-type
  (cond ((equal? target %host-type)
 (system-file-name-convention))
((string-contains-ci target "mingw")
 'windows)
(else
 'posix)

in 3.0.8 it aborts hard.

guile: uncaught exception:
Unbound variable:define-module
Cannot exit gracefully when init is in progress; aborting.

Anyway, I gave up and changed it back to 'posix always using this hack:

(let ((target (or "FIXME" ((@ (system base target) target-type)

with a MinGW-specific for cross-compiling to MinGW to 'windows always:

(let ((target (or "mingw" "FIXME" ((@ (system base target) target-type)

Ugh.  Ideas for a proper fix much appreciated!

Other than that, guile-mingw can still be built by doing

GUIX_PACKAGE_PATH=guix guix build guile-mingw

Greetings,
Janneke

-- 
Jan Nieuwenhuizen   | GNU LilyPond https://lilypond.org
Freelance IT https://JoyOfSource.com | Avatar® https://AvatarAcademy.com



[PATCH v3] DRAFT Support for x86_64-w64-mingw32.

2021-03-21 Thread Jan Nieuwenhuizen
Jan Nieuwenhuizen writes:

> Andy Wingo started a new discussion on libguile/bytevectors.c: 
>
>  810   810static inline void  
>  811   811twos_complement (mpz_t value, size_t size)  
>  812   812{  
>  813 -  unsigned long bit_count;  
>813   +  scm_t_unum bit_count;  
>
> Given that we require in-memory addressability for array elements,
> let's use ssize_t for this.

That makes some sense, but using ssize_t would change it from unsigned
to signed, are you sure we shouldn't choose size_t?

New patch attached using size_t, also up at


https://gitlab.com/janneke/guile/-/commit/b587e04e6b0e0fe37cb8774609a51ac7e04127a5

Greetings,
Janneke

>From b587e04e6b0e0fe37cb8774609a51ac7e04127a5 Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" 
Date: Tue, 16 Mar 2021 12:10:36 +0100
Subject: [PATCH v3] DRAFT Support for x86_64-w64-mingw32.
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8

On x86-64-MinGW the size of long is 4.  as long is used for
SCM_FIXNUM_BIT, that would mean incompatible .go files, and waste of
cell space.  So we would like to use long long, but the GMP interface
uses long.

to get around this, the x86-64-MinGW port now requires the use of
mini-gmp.  Mini-gmp has been changed to use intptr_t and uintptr_t.

Likewise, "numbers.h" now uses intptr_t instead of scm_inum_t and
uintptr_t instead of unsigned long.

This patch is still keeping SCM_I_INUM and SCM_I_INUMP, we could do

sed -i s/SCM_I_INUM/SCM_I_INTPTR/g $(find . -name '*.c' -o -name '*.h')

but hmm...WDYT?

* configure.ac: When x86_64-w64-mingw32, require mini-gmp.
* libguile/mini-gmp.h: Use intptr_t instead of long, uintptr_t instead
of unsigned long throughout.
* libguile/mini-gmp.c: Likewise.
* libguile/scm.h (SCM_INTPTR_T_BIT): New define.
* libguile/numbers.h (SCM_FIXNUM_BIT): Use it.
* libguile/numbers.c (L1): New macro.  Use it thoughout instead of 1L.
(verify): Use SCM_INTPTR_T_BIT.
(verify): Use SCM_INTPTR_T_MAX and SCM_INTPTR_T_MIN.
(scm_long2big): Rename to...
(scm_intptr2big): ..this.
(scm_ulong2big): Rename to...
(scm_uintptr2big): ..this.  Use them throughout, together with intptr_t,
uintptr_t instead of long and unsigned long.
* libguile/numbers.h (scm_intptr2big,scm_uintptr2big): New declarations.
(scm_from_intptr, scm_from_uintptr, scm_to_intptr, scm_to_uintptr): New
defines.
* libguile/arrays.c (make-shared-array): Use ssize_t instead of long.
* libguile/bytevectors.c (twos_complement): Use uintptr_t instead of
unsigned long.
* libguile/conv-integer.i.c (SCM_TO_TYPE_PROTO): Likewise.
* libguile/conv-uinteger.i.c (SCM_FROM_TYPE_PROTO): Likewise.
* libguile/hash.c (JENKINS_LOOKUP3_HASHWORD2): Likewise.
(narrow_string_hash, wide_string_hash, scm_i_string_hash,
scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash, scm_i_struct_hash, scm_raw_ihashq,
scm_raw_ihash): Use and return uintptr_t instead of unsigned long.
(scm_hashv, scm_hash): Use SCM_UINTPTR_T_MAX.
* libguile/hash.h (scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash): update prototypes.
* libguile/scmsigs.c (sigaction): Use intptr_t instead of long.
* libguile/strings.c (scm_i_make_symbol, (scm_i_c_make_symbol): Use
uintptr_t instead of unsigned long.
* libguile/strings.h (scm_i_make_symbol, (scm_i_c_make_symbol): Update
declacations.
* libguile/srfi-60.c: Use scm_uintptr2big, scm_intptr and variants
throughout.

Co-authored-by: Mike Gran 
Co-authored-by: Andy Wingo 

ssizet
---
 configure.ac   |   6 +
 libguile/arrays.c  |   6 +-
 libguile/bytevectors.c |  10 +-
 libguile/conv-integer.i.c  |   6 +-
 libguile/conv-uinteger.i.c |   8 +-
 libguile/hash.c|  46 ++--
 libguile/hash.h|  12 +-
 libguile/mini-gmp.c| 172 +++
 libguile/mini-gmp.h|  93 
 libguile/numbers.c | 441 ++---
 libguile/numbers.h |  34 ++-
 libguile/scm.h |   6 +-
 libguile/scmsigs.c |  14 +-
 libguile/srfi-60.c | 113 +-
 libguile/strings.c |  10 +-
 libguile/strings.h |   7 +-
 16 files changed, 501 insertions(+), 483 deletions(-)

diff --git a/configure.ac b/configure.ac
index bd49bf162f..3129c0e50a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -658,6 +658,12 @@ AC_ARG_ENABLE(mini-gmp,
 if test "x$enable_mini_gmp" = xyes || test "x$enable_mini_gmp" = xy; then
   SCM_I_GSC_ENABLE_MINI_GMP=1
 else
+  case $host in
+x86_64-*-mingw*)
+   AC_MSG_ERROR([mini-gmp is required; use --enable-mini-gmp])
+   ;;
+*) ;;
+  esac
   AC_LIB_HAVE_LINKFLAGS([gmp],[],[#include ], [mpz_import (0,0,0,0,0,0,0);])
   if test "x$HAVE_LIBGMP" != "xyes"; then
 AC_MSG_ERROR([GNU MP 4.1 or greater not found; either install it, or pass '--enable-mini-gmp' to use included less-optimal arbitrary-precision integer supp

[PATCH v2] DRAFT Support for x86_64-w64-mingw32.

2021-03-20 Thread Jan Nieuwenhuizen
Jan Nieuwenhuizen writes:

Hello,

> To get around this, the x86-64-MinGW port now requires the use of
> mini-gmp.  Mini-gmp has been changed to use mp_long and mp_ulong that
> are defined to long long and unsigned long long on this platform.
>
> Because we do not always use mini-gmp, "numbers.h" now introcudes
> scm_t_unum next to scm_t_inum Those are now used (almost) throughout
> instead of long and unsigned long.

After discussing on IRC, we decided not to introduce these new types and
instead use intptr_t and uintptr_t.  New patch attached.

Greetinsg,
Janneke

>From 21b7969c3730bde876d4322eb3d898214cef0723 Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" 
Date: Tue, 16 Mar 2021 12:10:36 +0100
Subject: [PATCH v2] DRAFT Support for x86_64-w64-mingw32.
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8

On x86-64-MinGW the size of long is 4.  as long is used for
SCM_FIXNUM_BIT, that would mean incompatible .go files, and waste of
cell space.  So we would like to use long long, but the GMP interface
uses long.

to get around this, the x86-64-MinGW port now requires the use of
mini-gmp.  Mini-gmp has been changed to use intptr_t and uintptr_t.

Likewise, "numbers.h" now uses intptr_t instead of scm_inum_t and
uintptr_t instead of unsigned long.

This patch is still keeping SCM_I_INUM and SCM_I_INUMP, we could do

sed -i s/SCM_I_INUM/SCM_I_INTPTR/g $(find . -name '*.c' -o -name '*.h')

but hmm...WDYT?

* configure.ac: When x86_64-w64-mingw32, require mini-gmp.
* libguile/mini-gmp.h: Use intptr_t instead of long, uintptr_t instead
of unsigned long throughout.
* libguile/mini-gmp.c: Likewise.
* libguile/scm.h (SCM_INTPTR_T_BIT): New define.
* libguile/numbers.h (SCM_FIXNUM_BIT): Use it.
* libguile/numbers.c (L1): New macro.  Use it thoughout instead of 1L.
(verify): Use SCM_INTPTR_T_BIT.
(verify): Use SCM_INTPTR_T_MAX and SCM_INTPTR_T_MIN.
(scm_long2big): Rename to...
(scm_intptr2big): ..this.
(scm_ulong2big): Rename to...
(scm_uintptr2big): ..this.  Use them throughout, together with intptr_t,
uintptr_t instead of long and unsigned long.
* libguile/numbers.h (scm_intptr2big,scm_uintptr2big): New declarations.
(scm_from_intptr, scm_from_uintptr, scm_to_intptr, scm_to_uintptr): New
defines.
* libguile/arrays.c (make-shared-array): Use intptr_t instead of long.
* libguile/bytevectors.c (twos_complement): Use uintptr_t instead of
unsigned long.
* libguile/conv-integer.i.c (SCM_TO_TYPE_PROTO): Likewise.
* libguile/conv-uinteger.i.c (SCM_FROM_TYPE_PROTO): Likewise.
* libguile/hash.c (JENKINS_LOOKUP3_HASHWORD2): Likewise.
(narrow_string_hash, wide_string_hash, scm_i_string_hash,
scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash, scm_i_struct_hash, scm_raw_ihashq,
scm_raw_ihash): Use and return uintptr_t instead of unsigned long.
(scm_hashv, scm_hash): Use SCM_UINTPTR_T_MAX.
* libguile/hash.h (scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash): update prototypes.
* libguile/scmsigs.c (sigaction): Use intptr_t instead of long.
* libguile/strings.c (scm_i_make_symbol, (scm_i_c_make_symbol): Use
uintptr_t instead of unsigned long.
* libguile/strings.h (scm_i_make_symbol, (scm_i_c_make_symbol): Update
declacations.
* libguile/srfi-60.c: Use scm_uintptr2big, scm_intptr and variants
throughout.

Co-authored-by: Mike Gran 
Co-authored-by: Andy Wingo 
---
 configure.ac   |   6 +
 libguile/arrays.c  |   6 +-
 libguile/bytevectors.c |  10 +-
 libguile/conv-integer.i.c  |   6 +-
 libguile/conv-uinteger.i.c |   8 +-
 libguile/hash.c|  46 ++--
 libguile/hash.h|  12 +-
 libguile/mini-gmp.c| 172 +++
 libguile/mini-gmp.h|  93 
 libguile/numbers.c | 441 ++---
 libguile/numbers.h |  34 ++-
 libguile/scm.h |   6 +-
 libguile/scmsigs.c |  14 +-
 libguile/srfi-60.c | 113 +-
 libguile/strings.c |  10 +-
 libguile/strings.h |   7 +-
 16 files changed, 501 insertions(+), 483 deletions(-)

diff --git a/configure.ac b/configure.ac
index bd49bf162f..3129c0e50a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -658,6 +658,12 @@ AC_ARG_ENABLE(mini-gmp,
 if test "x$enable_mini_gmp" = xyes || test "x$enable_mini_gmp" = xy; then
   SCM_I_GSC_ENABLE_MINI_GMP=1
 else
+  case $host in
+x86_64-*-mingw*)
+   AC_MSG_ERROR([mini-gmp is required; use --enable-mini-gmp])
+   ;;
+*) ;;
+  esac
   AC_LIB_HAVE_LINKFLAGS([gmp],[],[#include ], [mpz_import (0,0,0,0,0,0,0);])
   if test "x$HAVE_LIBGMP" != "xyes"; then
 AC_MSG_ERROR([GNU MP 4.1 or greater not found; either install it, or pass '--enable-mini-gmp' to use included less-optimal arbitrary-precision integer support.])
diff --git a/libguile/arrays.c b/libguile/arrays.c
index 0a919515b5..a49abcced3 100644
--- a/libguile/arrays

[PATCH] DRAFT Support for x86_64-w64-mingw32.

2021-03-17 Thread Jan Nieuwenhuizen
Hi!

On x86-64-MinGW the size of LONG is 4.  As LONG is used for
SCM_FIXNUM_BIT, that would mean incompatible .go files, and waste of
cell space.  So we would like to use LONG LONG, but the GMP interface
uses LONG.

To get around this, the x86-64-MinGW port now requires the use of
mini-gmp.  Mini-gmp has been changed to use mp_long and mp_ulong that
are defined to LONG LONG and UNSIGNED LONG LONG on this platform.

Because we do not always use mini-gmp, "numbers.h" now introcudes
SCM_I_UNUM NEXT to SCM_I_INUM.  Those are now used (almost) throughout
instead of LONG and UNSIGNED LONG.

As discussed on IRC, this patch also lives here


https://gitlab.com/janneke/guile/-/commit/ac929750129cf396baee9cb45850d75ea9e7e1bd

You can build it by doing

   GUIX_PACKAGE_PATH=guix guix build --target=x86_64-w64-mingw32 guile-mingw

on that branch and using guile.cmd from the source tree, run something
like

   wine64 cmd /c guile -c '(display "hello\n")'

Greetings,
Janneke

>From ac929750129cf396baee9cb45850d75ea9e7e1bd Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" 
Date: Tue, 16 Mar 2021 12:10:36 +0100
Subject: [PATCH] DRAFT Support for x86_64-w64-mingw32.
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8

On x86-64-MinGW the size of LONG is 4.  As LONG is used for
SCM_FIXNUM_BIT, that would mean incompatible .go files, and waste of
cell space.  So we would like to use LONG LONG, but the GMP interface
uses LONG.

To get around this, the x86-64-MinGW port now requires the use of
mini-gmp.  Mini-gmp has been changed to use mp_long and mp_ulong that
are defined to LONG LONG and UNSIGNED LONG LONG on this platform.

Because we do not always use mini-gmp, "numbers.h" now introcudes
SCM_I_UNUM NEXT to SCM_I_INUM.  Those are now used (almost) throughout
instead of LONG and UNSIGNED LONG.

* configure.ac: When x86_64-w64-mingw32, require mini-gmp.
* libguile/mini-gmp.h (MP_LONG_MAX, MP_LONG_MIN): New defines.
(mp_long, mp_ulong): New typedefs.  USe them throughout, replacing long
and unsigned long.
* libguile/mini-gmp.c: Likewise.
* libguile/scm.h (SCM_LONG_LONG_BIT): New define.
* libguile/numbers.h (SCM_FIXNUM_BIT)[__MINGW32__ && __x86_64__]: Use
it.
(SCM_SIZEOF_INUM, SCM_INUM_BIT, SCM_INUM_MIN, SCM_INUM_MAX,
SCM_UNUM_MAX): New defines.
(scm_t_unum): New typedef.
* libguile/numbers.c (L1): New macro.  Use it thoughout instead of 1L.
(verify): Use SCM_INUM_BIT.
(verify): Use SCM_INUM_MAX and SCM_INUM_MIN.
(scm_long2big): Rename to...
(scm_inum2big): ..this.
(scm_ulong2big): Rename to...
(scm_unum2big): ..this.  Use them throughout, together with scm_t_inum,
scm_t_unum instead of long and unsigned long.
* libguile/numbers.h (scm,inum2big,scm_unum2big): New declarations.
(scm_from_inum, scm_from_unum, scm_to_inum, scm_to_unum): New
defines.
* libguile/arrays.c (make-shared-array): Use scm_t_inum instead of long.
* libguile/bytevectors.c (twos_complement): Use scm_t_unum instead of
unsigned long.
* libguile/conv-integer.i.c (SCM_TO_TYPE_PROTO): Likewise.
* libguile/conv-uinteger.i.c (SCM_FROM_TYPE_PROTO): Likewise.
* libguile/hash.c (JENKINS_LOOKUP3_HASHWORD2): Likewise.
(narrow_string_hash, wide_string_hash, scm_i_string_hash,
scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash, scm_i_struct_hash, scm_raw_ihashq,
scm_raw_ihash): Use and return scm_t_unum instead of unsigned long.
(scm_hashv, scm_hash): Use SCM_UNUM_MAX.
* libguile/hash.h (scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash): update prototypes.
* libguile/scmsigs.c (sigaction): Use scm_t_inum instead of long.
* libguile/strings.c (scm_i_make_symbol, (scm_i_c_make_symbol): Use
scm_t_unum instead of unsigned long.
* libguile/strings.h (scm_i_make_symbol, (scm_i_c_make_symbol): Update
declacations.
* libguile/srfi-60.c: Use scm_unum2big, scm_inum2big and variants
throughout.

Co-authored-by: Mike Gran 
Co-authored-by: Andy Wingo 
---
 configure.ac   |   6 ++
 libguile/arrays.c  |   2 +-
 libguile/bytevectors.c |  10 +--
 libguile/conv-integer.i.c  |   6 +-
 libguile/conv-uinteger.i.c |   8 +-
 libguile/hash.c|  46 +-
 libguile/hash.h|  12 ++-
 libguile/mini-gmp.c| 172 ++---
 libguile/mini-gmp.h|  97 +++--
 libguile/numbers.c |  75 
 libguile/numbers.h |  40 -
 libguile/scm.h |   6 ++
 libguile/scmsigs.c |  14 +--
 libguile/srfi-60.c | 111 
 libguile/strings.c |  10 +--
 libguile/strings.h |   7 +-
 16 files changed, 339 insertions(+), 283 deletions(-)

diff --git a/configure.ac b/configure.ac
index bd49bf162f..3129c0e50a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -658,6 +658,12 @@ AC_ARG_ENABLE(mini-gmp,
 if test "x$enable_mini_gmp" = xyes || test "x$enable_mini_gmp" = xy; then
   SCM_I_GSC_ENABLE_MINI_GMP=1
 else
+  case $host in
+

[PATCH wip-mingw-guile-2.2] mingw: Support for x86_64-w64-mingw32.

2020-08-14 Thread Jan Nieuwenhuizen
61,12 +963,13 @@ immediate, and @code{#f} otherwise."
   (if (exact-integer? x)
   ;; Object is an immediate if it is a fixnum on the target.
   (call-with-values (lambda ()
-  (case (asm-word-size asm)
+  (case (asm-fixnum-size asm)
 ((4) (values(- #x2000)
 #x1fff))
 ((8) (values(- #x2000)
 #x1fff))
-        (else (error "unexpected word size"
+(else (error "unexpected fixnum-size:"
+     (asm-fixnum-size asm)
 (lambda (fixnum-min fixnum-max)
   (and (<= fixnum-min x fixnum-max)
(let ((fixnum-bits (if (negative? x)
-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com


-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com


Re: unhandled constant?

2020-02-02 Thread Jan Nieuwenhuizen
Han-Wen Nienhuys writes:

> [guile1.8]$ grep -ir define-syntax-rule .
>
> (empty)
>
> I  need something that works in GUILE 1.8 too.

Guile 1.8 has syntax-rules after you include (ice-9 syncase).
(define-syntax-rule foo ...) is just syntactic sugar for (define-syntax
foo (syntax-rules () ...); see the manual.

Combined with cond-expand, maybe that could work?

janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Re: Logo baseline

2020-01-19 Thread Jan Nieuwenhuizen
Ludovic Courtès writes:

> What’s about you?  What’s Guile to you?  :-)

Guile is the force that binds GNU together.  Guile was intended to
extend (all) GNU programs, truly empowering the user.  You made Guile
into a great language for writing programs.  Now Guile even creates a
coherent GNU System, through Guix.

Moving from Python to Guile was a gentle path towards a more functional
approach of writing programs which reduces accidental complexity and
fits much better with how my mind works.

What puzzles me is the long road it took me to reach this point, more
than 20 years via C, C++ and Python.  When I look at GNU projects like
Glibc or GCC moving from awk/sed/perl to Python for scripts instead of
Guile I can't help thinking: Oh my, they are where I was 20 years ago;
what a long path we still have before us.

Greetings,
janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Re: [PATCH] Add string-replace-substring to (ice-9 string-fun)

2020-01-05 Thread Jan Nieuwenhuizen
Andy Wingo writes:

> On Fri 20 Dec 2019 18:32, lloda  writes:
>
>> This patch adds string-replace-substring that wingo posted to the
>> mailing list to (ice-9 strings). This is a commonly used function and a
>> good implementation isn't trivial, so I think it deserves inclusion.
>
> I didn't know that this module existed :)  Sure, why not.  Please fix
> the commit message when you push.

That's great!  This is one of the things that has always amazed and
annoyed me to be missing and I have written several half-baken
implementations of it when I needed something like it.

Would it be too much to ask for some documentation to go with it, so
that we will be able to find it?

Greetings,
janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Guile and Mes [WAS: conflicts in the gnu project now affect guile]

2019-10-19 Thread Jan Nieuwenhuizen
Mark H Weaver writes:

Hi Mark,

>> I have been worrying a bit about this change because I do not see how to
>> implement it in Mes.
>
> There's a straightforward way to translate a body containing mixed
> definitions and expressions into a 'letrec*'.  It's illustrated in the
> commit log, and in the manual:
>
>   
> https://git.savannah.gnu.org/cgit/guile.git/commit/?id=20535922147cd5992330962aaa5c4986563fc905
>   
> https://git.savannah.gnu.org/cgit/guile.git/tree/doc/ref/api-binding.texi?id=5284b9b9c6cecc404a912acaefce2b883ac0dbba#n284

Thanks!  I really appreciate your help.  Andy found me on IRC and also
helped me with two similar suggestions.  It's great that you both have
helped take away my worries here.

Even better, these solutions got me thinking about how Mes implements
macros and Guile compatibility.  Our next big target for Mes should be
to remove define-macro support from eval_apply and load Guile's
psyntax-pp.scm.  Probably best to start playing with Guile stable-2.0
and first reduce psyntax.scm to the bare minimum, regenerate
psyntax-pp.scm and get a easier success and work from that.

Greetings,
janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Re: conflicts in the gnu project now affect guile

2019-10-17 Thread Jan Nieuwenhuizen
Mark H Weaver writes:

> Andy Wingo  writes:
>> Before the RMS/GNU/FSF conversation started, Mark Weaver left Guile, for
>> essentially unrelated reasons.  He threatened to leave because he wished
>> to be consulted before I landed mixed definitions and expressions and
>> shipped them in the 2.9.4 release;
>
> The funny thing is, I don't actually have a strong opinion on this
> particular change.
>
> What I *do* have a strong opinion on is that you made the decision
> unilaterally, without discussion on the mailing list

I have been worrying a bit about this change because I do not see how to
implement it in Mes.  I did not speak up because I believe that our
bootstrapping efforts should not hold Guile development back.

> Ludovic and I only found out about the change after the public
> announcements had already been made.
>
> Can you understand why I consider this behavior to be dictatorial?

Yes, I can see that now.  However, having met Andy I could not have
imagined that something like that could have been his motivation.  It
would be great if we all could spend some time together.

> For what it's worth, despite our disagreements, I still sincerely
> believe that you are acting in good faith, and fighting for what you
> believe is right.  I hope that you can believe that I'm doing the same.

When you left that was pretty discouraging for me: I enjoyed and much
appreciated your recent help with the Guix bootstrap.  Thank you for
that!  I am happy you have decided to come back.

Greetings,
jannneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Re: FOSDEM 2019

2019-02-04 Thread Jan Nieuwenhuizen
Ludovic Courtès writes:

Hello!

> Mikael Djurfeldt  skribis:
>
>> It was a great experience and joy for me to meet some of you at FOSDEM
>> 2019. Thank you all!
>
> Seconded, that was awesome!  Meeting Guilers, both newcomers and
> old-timers :-), was just great!

Thirded :-), that was so amazing, thank you all!

janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Re: Compiling guile-2.2.4 for mingw

2018-11-20 Thread Jan Nieuwenhuizen
Christoph Buck writes:

> Currently i try to compile guile-2.2.4 under mingw64 bit.

Oh, interesting!

> I had some minor issues in the c source code which i managed to fix by
> applying some of the patches from
> https://github.com/mkeeter/guile-mingw. Namely
>
> 1) 0003-winsock-compat.mingw.patch
> 2) 0004-start_child.mingw.patch

What is the relation with or status of the wip-mingw-guile branch on
savannah?

http://git.savannah.gnu.org/cgit/guile.git/log/?h=wip-mingw-guile-2.2

Does this build on top of that, what would be needed to get
wip-mingw-guile merged?

janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



[PATCH] debugger: Support generics. WIP.

2018-09-12 Thread Jan Nieuwenhuizen
Hi!

I'm looking at the debugger again and have found a number of things*)
that I would like to fix.  My first attempt is for GOOPS support: I want
,break-at-source FILE LINE to also support breaking if LINE happens to
be in a define-method.

The attached patch tries to add this support, but there's still a
problem: the trap doesn't work.  I'll keep on looking but some help
would be much appreciated; e.g., I'm doubt if using (oop goops) in
(system ...) modules is OK.

Before this patch:

scheme@(break-at-source)> ,break-at-source "break-at-source.scm" 21
While executing meta-command:
No procedures found at ~a:~a. "break-at-source.scm" 21

with only (system xref) patched:

scheme@(break-at-source)> ,break-at-source "break-at-source.scm" 21
;;; WARNING (no instructions found for break-at-source.scm : 21)
Trap 0: Breakpoint at break-at-source.scm:21.

Using this patch there is no warning anymore and the trap is reported to
be set... Here's what happens

--8<---cut here---start->8---
$ meta/build-env guile-tools compile -o break-at-source.go break-at-source.scm
wrote `break-at-source.go'
13:28:59 janneke@dundal:~/src/guile/build [env]
$ meta/build-env guile -L . -C .
GNU Guile 2.2.4.14-8b75b
Copyright (C) 1995-2017 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> ,m (break-at-source)

scheme@(break-at-source)> ,break-at-source "break-at-source.scm" 21
Trap 0: Breakpoint at break-at-source.scm:21.
scheme@(break-at-source)> (main)

main1
main2
test1
test2
test3
main3
scheme@(break-at-source)> ,break-at-source "break-at-source.scm" 16
Trap 1: Breakpoint at break-at-source.scm:16.
scheme@(break-at-source)> (main)
main1
main2
Trap 1: Breakpoint at break-at-source.scm:16
Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(break-at-source) [1]>
--8<---cut here---end--->8---

Where should I look next, what could i do next?
janneke

*) Other debugger things I would like to look at
   - also find source locations in files that were compiled using
  (compile-file ... 'absolute)
   - have ,frame and ,backtrace use GNU style error messages (I worked
 on this long ago but only have an ugly solution)
   - have procedure parameters show up in ,locals
   - get Emacs GUD integration working ootb

>From 13516b7fbee7baee20d6255619b57e3934800465 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen 
Date: Wed, 12 Sep 2018 11:58:43 +0200
Subject: [PATCH] debugger: Support generics.  WIP.

Before this patch:

scheme@(break-at-source)> ,break-at-source "break-at-source.scm" 21
While executing meta-command:
No procedures found at ~a:~a. "break-at-source.scm" 21

with only (system xref) patched:

scheme@(break-at-source)> ,break-at-source "break-at-source.scm" 21
;;; WARNING (no instructions found for break-at-source.scm : 21)
Trap 0: Breakpoint at break-at-source.scm:21.

but the breakpoint does not work, execution continues right through trap.

With also (system vm traps) patched:

scheme@(break-at-source)> ,break-at-source "break-at-source.scm" 21
Trap 0: Breakpoint at break-at-source.scm:21.

Yay!...but alas, the breakpoint still does not work, execution continues
right through trap.

* module/system/vm/traps.scm (generic-sources-by-line): New procedure.
(program-sources-by-line): Use it to support generics.
* module/system/xref.scm (generic-callee-rev-vars): New procedure.
(procedure-callee-rev-vars): Use it to support generics.
(generic-sources): New procedure.
(procedure-sources): Use it to support generics.
* examples/break-at-source.scm: New file.
---
 examples/break-at-source.scm | 22 ++
 module/system/vm/traps.scm   |  9 +
 module/system/xref.scm   | 14 ++
 3 files changed, 45 insertions(+)
 create mode 100644 examples/break-at-source.scm

diff --git a/examples/break-at-source.scm b/examples/break-at-source.scm
new file mode 100644
index 0..88d905bd1
--- /dev/null
+++ b/examples/break-at-source.scm
@@ -0,0 +1,22 @@
+#!
+cp ../examples/break-at-source.scm .
+meta/build-env guile-tools compile -o break-at-source.go break-at-source.scm
+meta/build-env guile -L examples -C examples
+,m (break-at-source)
+,break-at-source "break-at-source.scm" 21
+(main)
+!#
+
+(define-module (break-at-source)
+  #:use-module (oop goops))
+
+(define (main . args)
+  (display "main1\n")
+  (display "main2\n")
+  (test args)  ; 16
+  (display "main3\n"))
+
+(define-method (test (o ))
+  (display "test1\n")
+  (display "test2

Re: [ANN] nyacc version 0.86.0 released

2018-09-08 Thread Jan Nieuwenhuizen
Matt Wette writes:

> I have released nyacc version 0.86.0.  This release includes the
> following:

Congratulations with the release!... and

> 3) I replaced use of (ice-9 regexp) for the bootstrapper team. (you know
>who you are)

...many thanks!

I tried several times to upgrade Nyacc, tried to create patches and failed.

This release works amazingly ootb for me and I made patches for GuixSD
and the the #bootstrappable effort in wip-bootstrap because I found that
mes.c compiles fine with Nyacc 0.86.0, running on Guile or Mes alike.
Really great!

Trying to create a package, I found this one test (out of 102 tests) to
fail:

--8<---cut here---start->8---
int
main ()
{
  int a = 0b11;
}
--8<---cut here---end--->8---

It works fine with 0.80.4*

janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Re: c99 support

2018-06-24 Thread Jan Nieuwenhuizen
Andy Wingo writes:

> Is there anyone who compiles Guile with a compiler that does not support
> C99?  If so, please give platform and compiler.

As you probably know, I'm currently looking into bootstrapping GuixSD
from source.

I'd like to see Guile become more bootstrappable, i.e., less C code and
perhaps a BOOTSTRAP define to remove all non-essential features and
possibly target bootstrapping it before bootstrapping gcc or even tcc.

I see C99 more as a feature than a problem.  Nyacc supports C99, hardly
any recent software can be built without it.

Greetings,
janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Re: wip-bootstrap updated

2018-05-03 Thread Jan Nieuwenhuizen
Ludovic Courtès writes:

>> I've updated the wip-bootstrap branch[0] for Mes[1] 0.13.

> Very nice!

Thanks!

> At some point people were wondering whether using tcc as a base was the
> best course of action, after all, given that it needs to be heavily
> patched and that MesCC is making good progress.  What’s your take on
> this now?

Yes, I'm wondering about that quite often.  At the reproducible-builds
conference, Ricardo was inspired to try using Mes to bootstrap Guile
instead of tcc.  That did really work yet, mainly because Mes didn't
recursively expand macros. Recursive macro expansion was added in Mes
0.12, I'd love to revisit the direct Guile bootstrap path.

At the moment, tcc seems the best of the worst.  Tcc is the only
somewhat simple C compile that I know of that can build gcc.  I'd be
very happy to hear any alternatives.

> Also, does M1 support all the architectures Guix currently supports?

Currently, Mes only supports x86.  The low level tools (hex0, hex1, M0
M1 and M2-Planet) become gradually more architecture independent, with
implementations for x86, amd64, amd and Knight VM.

My first aim is to have a working gcc for x86, a pragmatic choice for
me.

> Definitely.  I think we can improve things incrementally, we don’t have
> to go straight to the ultimate solution.  So if we can make small
> changes to our bootstrap graph and already remove 10MB out of these
> 250MB, let’s just do that.

Yes, that's my strategy...however I do not see how to replace anything
until we have bootstrapped a working Gcc [or Guile?].  So all effort is
focussed on that now.

The past months I've been working to improve Mes Scheme, to make it
a viable option for compiling tcc.  Now that's done, I'll be looking
at the tcc and MesCC compiler again.

>> The plan is to replace the mes.M1 seed with mes.M2

> Exciting.

Yes, and it's so much fun over at #bootstrappable.  M2-Planet just
got anonymous structs and function pointers -- that should be enough
for mes.c :-)

Greetings,
janneke

-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Re: [ANN] nyacc 0.82.1 released

2017-11-11 Thread Jan Nieuwenhuizen
Matt Wette writes:

Hey Matt,

> Nyacc 0.82.1 has been released.

Congrats!

It's been a while but in 0.82.0 I found a regression of a bug that you
fixed earlier, I think in 0.80.4

https://lists.gnu.org/archive/html/guile-user/2017-06/msg3.html

I've attached the problematic file again.  It's also still present in 0.82.1

$ guile
GNU Guile 2.2.2
Copyright (C) 1995-2017 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (use-modules (nyacc lalr))
scheme@(guile-user)> *nyacc-version*
$1 = "0.82.1"
scheme@(guile-user)> (use-modules (nyacc lang c99 parser))
scheme@(guile-user)> (with-input-from-file "def-bwl.c" parse-c99)
(unknown):1: parse failed at state 89, on input "DEF_BWL"
(unknown):1: C99 parse error
$2 = #f

Greetings,
janneke



def-bwl.c
Description: Binary data

-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com


Re: Recovering from a bad installation

2017-08-05 Thread Jan Nieuwenhuizen
Ricardo Wurmus writes:

> If you forgot to set the file system label for the root file system to the
> label you specified in the operating system configuration file then you won't
> be able to boot.

What about adding a check if / can be mounted before installing Grub?

janneke

-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



#if __GNUC__ > 2 ..

2017-06-18 Thread Jan Nieuwenhuizen
Hi Matt!

When I use Nyacc to parse things like

 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
 #else
 # define _GL_ATTRIBUTE_PURE /* empty */
 #endif

I get

foo.c:1: undefined identifier: "__GNUC__"
foo.c:1: CPP error

I have been avoiding this using #:cpp-defs '( ... "__GNUC__=0" ) for Mes
but for real projects that put gcc-specific things inside

#ifdef __GCC__
#endif

that does not work.  I'm trying to compile different things currently,
like 8cc, pcc and Guile's eval.c-- without much success ATM--, changing
and editing lots of things like these defines but it is getting hairy
now.

Greetings,
janneke

-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Re: srfi-1 take and drop seriously broken

2016-11-19 Thread Jan Nieuwenhuizen
Jan Synáček writes:

> scheme@(guile-user)> ,use (srfi srfi-1)
> scheme@(guile-user)> (take (list 1 2 3) 4)
> ERROR: In procedure list-head:
> ERROR: In procedure list-head: Wrong type argument in position 1
> (expecting pair): ()

That's expected.

> scheme@(guile-user) [1]> (drop (list 1 2 3) 4)
> ERROR: In procedure list-tail:
> ERROR: In procedure list-tail: Wrong type argument in position 1
> (expecting pair): ()

That too.

> Please, tell me that this is just a mistake...

It's just a mistake!

> This can't be true. I still can't believe it. This is from
> 2.0.11. Please, tell me that the implementation is fixed in 2.2.

You'd have to give me more clues about what it is that puzzles you
and why.

> Yours truly puzzled,

Do you possibbly mean something like

--8<---cut here---start->8---
scheme@(guile-user)> (use-modules (srfi srfi-1))
scheme@(guile-user)> (take '(list 1 2 3) 4)
$1 = (list 1 2 3)
scheme@(guile-user)> (drop '(list 1 2 3) 4)
$2 = ()
--8<---cut here---end--->8---

Greetings,
Jan

-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



[PATCH 1/2] PRELIMINARY: psyntax: Remove uses of syntax-session-id.

2016-11-02 Thread Jan Nieuwenhuizen
From: Mark H Weaver 

This is an attempted fix for ,
but I'm not yet confident in its correctness.

* module/ice-9/boot-9.scm (module-generate-unique-id!): New procedure.
  (module): Add 'next-unique-id' field.
  (the-root-module): Inherit 'next-unique-id' value from early stub.
  (make-module, make-autoload-interface): Adjust calls to
  module-constructor.
* module/ice-9/psyntax.scm (gen-label, new-mark): Generate unique
  identifiers from the module name and the per-module unique-id.
---
 module/ice-9/boot-9.scm | 25 +
 module/ice-9/psyntax-pp.scm | 15 +--
 module/ice-9/psyntax.scm| 13 ++---
 3 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 7f62097..f1d684d 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -1,6 +1,6 @@
 ;;; -*- mode: scheme; coding: utf-8; -*-
 
- Copyright (C) 1995-2014  Free Software Foundation, Inc.
+ Copyright (C) 1995-2014, 2016  Free Software Foundation, Inc.
 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
@@ -374,6 +374,12 @@ a-cont
 (define (module-ref module sym)
   (let ((v (module-variable module sym)))
 (if v (variable-ref v) (error "badness!" (pk module) (pk sym)
+(define module-generate-unique-id!
+  (let ((next-id 0))
+(lambda (m)
+  (let ((i next-id))
+(set! next-id (+ i 1))
+i
 (define (resolve-module . args)
   #f)
 
@@ -1973,7 +1979,8 @@ written into the port is returned."
  submodules
  submodule-binder
  public-interface
- filename)))
+ filename
+ next-unique-id)))
 
 
 ;; make-module  size uses binder
@@ -1997,7 +2004,7 @@ written into the port is returned."
   (make-hash-table)
   '()
   (make-weak-key-hash-table 31) #f
-  (make-hash-table 7) #f #f #f))
+  (make-hash-table 7) #f #f #f 0))
 
 
 
@@ -2579,6 +2586,11 @@ written into the port is returned."
   (let ((m (make-module 0)))
 (set-module-obarray! m (%get-pre-modules-obarray))
 (set-module-name! m '(guile))
+
+;; Inherit next-unique-id from preliminary stub of
+;; %module-get-next-unique-id! defined above.
+(set-module-next-unique-id! m (module-generate-unique-id! #f))
+
 m))
 
 ;; The root interface is a module that uses the same obarray as the
@@ -2607,6 +2619,11 @@ written into the port is returned."
   the-root-module
   (error "unexpected module to resolve during module boot" name)))
 
+(define (module-generate-unique-id! m)
+  (let ((i (module-next-unique-id m)))
+(set-module-next-unique-id! m (+ i 1))
+i))
+
 ;; Cheat.  These bindings are needed by modules.c, but we don't want
 ;; to move their real definition here because that would be unnatural.
 ;;
@@ -2936,7 +2953,7 @@ written into the port is returned."
   #:warning "Failed to autoload ~a in ~a:\n" sym name
 (module-constructor (make-hash-table 0) '() b #f #f name 'autoload #f
 (make-hash-table 0) '() (make-weak-value-hash-table 
31) #f
-(make-hash-table 0) #f #f #f)))
+(make-hash-table 0) #f #f #f 0)))
 
 (define (module-autoload! module . args)
   "Have @var{module} automatically load the module named @var{name} when one
diff --git a/module/ice-9/psyntax-pp.scm b/module/ice-9/psyntax-pp.scm
index d797665..207d534 100644
--- a/module/ice-9/psyntax-pp.scm
+++ b/module/ice-9/psyntax-pp.scm
@@ -297,7 +297,12 @@
  (values x (car w)
(gen-label
  (lambda ()
-   (string-append "l-" (session-id) (symbol->string (gensym "-")
+   (let ((mod (current-module)))
+ (simple-format
+   #f
+   "l-~s~s"
+   (module-generate-unique-id! mod)
+   (module-name mod)
(gen-labels
  (lambda (ls)
(if (null? ls) '() (cons (gen-label) (gen-labels (cdr ls))
@@ -1001,7 +1006,13 @@
  (lambda ()
(rebuild-macro-output
  (p (source-wrap e (anti-mark w) s mod))
- (gensym (string-append "m-" (session-id) "-")
+ (let ((mod (current-module)))
+   (string->symbol
+ (simple-format
+   #f
+   "m-~s~s"
+   (module-generate-unique-id! mod)
+   (module-name mod)))
(expand-body
  (lambda (body outer-form r w mod)
(let* ((r (cons '("placeholder" placeholder) r))
diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm
index 88df4c7..8fa0ff3 100644
--- a/module/ice-9/psyntax.scm
+++ b/module/ice-9/psyntax.scm
@@ -1,7 +1,7 @@
  -*-scheme-*-
 
  Copyright (C) 2001, 2003, 2006, 2009, 2010, 

[PATCH 2/2] psyntax: fix gen-label for unset module.

2016-11-02 Thread Jan Nieuwenhuizen
* module/ice-9/boot-9.scm (generate-unique-id!): New function.
  (module-generate-unique-id!): Use it.
* module/ice-9/psyntax.scm (gen-label): Use it to cater for unset
  module.
* module/ice-9/psyntax-pp.scm: Regenerate.
---
 module/ice-9/boot-9.scm | 3 ++-
 module/ice-9/psyntax-pp.scm | 2 +-
 module/ice-9/psyntax.scm| 6 --
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index f1d684d..e18818e 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -374,12 +374,13 @@ a-cont
 (define (module-ref module sym)
   (let ((v (module-variable module sym)))
 (if v (variable-ref v) (error "badness!" (pk module) (pk sym)
-(define module-generate-unique-id!
+(define generate-unique-id!
   (let ((next-id 0))
 (lambda (m)
   (let ((i next-id))
 (set! next-id (+ i 1))
 i
+(define module-generate-unique-id! generate-unique-id!)
 (define (resolve-module . args)
   #f)
 
diff --git a/module/ice-9/psyntax-pp.scm b/module/ice-9/psyntax-pp.scm
index 207d534..c47df7f 100644
--- a/module/ice-9/psyntax-pp.scm
+++ b/module/ice-9/psyntax-pp.scm
@@ -301,7 +301,7 @@
  (simple-format
#f
"l-~s~s"
-   (module-generate-unique-id! mod)
+   (if mod (module-generate-unique-id! mod) (generate-unique-id! #f))
(module-name mod)
(gen-labels
  (lambda (ls)
diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm
index 8fa0ff3..7e5c863 100644
--- a/module/ice-9/psyntax.scm
+++ b/module/ice-9/psyntax.scm
@@ -634,8 +634,10 @@
 (define (gen-label)
   (let ((mod (current-module)))
 (simple-format #f "l-~s~s"
-   (module-generate-unique-id! mod)
-   (module-name mod
+(if mod
+(module-generate-unique-id! mod)
+(generate-unique-id! #f))
+(module-name mod
 
 (define gen-labels
   (lambda (ls)
-- 
2.10.1




Re: bug#20272: Support reproducible builds

2016-11-02 Thread Jan Nieuwenhuizen
Hi!

I have rebased Mark's patch to master and added a fix on top of that,
needed on 2.1 to pass make check.

Also, I found that to pass make check these patches depend on
(yesterday's) latest master commit

Use atomics for async interrupts

that patch seems to depend on (at least git rebase-wise)

 Deprecate user asyncs
 Deprecate arbiters
 Fold 2.1.4 news into 2.2 news

Having these 6 patches on top op 2.1.4 has guile produce deterministic
.go files...mostly.

My client code is seems to be happy with this, however Guix tells me
that some files are still not deterministic:

lib/guile/2.2/ccache/ice-9/peg/cache.go
lib/guile/2.2/ccache/system/repl/coop-server.go
lib/libguile-2.2.so.0.0.0

and in Guix's debug output (only after I removed this hoping to get
guile-next reproducible, guix informed me about the plain output
nondeterminism?)

lib/guile/2.2/ccache/ice-9/peg/cache.go.debug
lib/guile/2.2/ccache/web/server/http.go.debug

Any ideas on what's causing this remaining nondeterminism?  Would it be
a good idea to include these patches in Guix to give them some testing?

Greetings,
Jan.




Re: Setting up CI for Guile

2016-10-06 Thread Jan Nieuwenhuizen
Thompson, David writes:

>> I'm a big fan of CI (automated testing), and maybe you are too. I'd
>> love to have CI for reviewing patches of Guile.
>
> This is a good idea.

+1

> That's unfortunate.  It's important to build from scratch, which means
> bootstrapping the compiler, which indeed takes awhile, but patches
> generally take days or longer to be reviewed and merged so a few hours
> is no big deal, IMO.  The GNU Guix project is working on a replacement
> for its current CI system at hydra.gnu.org that runs Hydra from the
> Nix project, named Cuirass, so I think we should try to use that
> instead of GitLab.

I so much like this idea, that I contributed some patches to Cuirass to
do exactly this.  Next to being a CI dedicated for GuixSD to track any
package's git.  Here's the discussion

https://lists.gnu.org/archive/html/guix-devel/2016-09/threads.html#01338

patches are in  Cuirass now and anyone is much encouraged to play.

> I think this is a wonderful idea that could use a new implementation.
> Thanks for getting the ball rolling with the proof-of-concept!

Yes!

Greetings,
Jan

-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



[PATCH] Initial GUD integration support.

2016-09-25 Thread Jan Nieuwenhuizen
Hi!

I'm trying to resurrect and finish my Emacs' Grand Unified Debugger
(GUD) integration patch, but I cannot get latest Guile master's debugger
to respect breakpoints?

This patch mainly tries to have Guile use GNU style error messages when
printing backtraces.  Meanwhile, the Emacs side of thes patches has been
integrated so that should be easier to test now.

With attached patch, try:

$ meta/guile -L ../examples

GNU Guile 2.1.4
Copyright (C) 1995-2016 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> ,m (gud-break)
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;   or pass the --no-auto-compile argument to disable.
;;; compiling ../examples/gud-break.scm
;;; compiled 
/home/janneke/src/guile/build/cache/guile/ccache/2.2-LE-8-3.9/home/janneke/src/guile/examples/gud-break.scm.go
scheme@(gud-break)> ,br main
Trap 0: Breakpoint at #.
scheme@(gud-break)> (main)
((line . 35) (column . 29) (filename . gud-break.scm)):hello world
set: a=1
set: b=2
set: c=3
set: d=4
((line . 50) (column . 30) (filename . gud-break.scm)):leaving...
((line . 51) (column . 31) (filename . gud-break.scm)):goodbye world
scheme@(gud-break)> ,break-at /home/janneke/src/guile/examples/gud-break.scm 36

;;; WARNING (no instructions found for 
/home/janneke/src/guile/examples/gud-break.scm : 35)
Trap 1: Breakpoint at /home/janneke/src/guile/examples/gud-break.scm:36.
scheme@(gud-break)> (main)
((line . 35) (column . 29) (filename . gud-break.scm)):hello world
set: a=1
set: b=2
set: c=3
set: d=4
((line . 50) (column . 30) (filename . gud-break.scm)):leaving...
((line . 51) (column . 31) (filename . gud-break.scm)):goodbye world
scheme@(gud-break)>

Greetings,
Jan

>From 0b220974b0288a0de1d892b765ce609033b1 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Tue, 5 Aug 2014 12:34:09 +0200
Subject: [PATCH] Initial GUD integration support.

* examples/gud-break.scm: New example; showing initial GUD
integration.
* module/system/repl/debug.scm (debug-prompt): New procedure;
gdb-like debug prompt.  Experimental!
* module/system/repl/error-handling.scm (call-with-error-handling):
* module/system/repl/command.scm (step, step-instruction, next)
(next-instruction): Use it.
---
 examples/gud-break.scm| 56 
 module/system/repl/command.scm|  8 ++--
 module/system/repl/debug.scm  | 80 +++
 module/system/repl/error-handling.scm |  3 +-
 4 files changed, 142 insertions(+), 5 deletions(-)
 create mode 100644 examples/gud-break.scm

diff --git a/examples/gud-break.scm b/examples/gud-break.scm
new file mode 100644
index 000..dbef6f3
--- /dev/null
+++ b/examples/gud-break.scm
@@ -0,0 +1,56 @@
+#! /bin/sh
+# -*-scheme-*-
+exec guile -e main -s "$0" "$@"
+!#
+;; Experimental GUD support for Guile REPL
+;; Find a gud.el that you want to patch, e.g.
+;; zcat /usr/share/emacs/24.3/lisp/progmodes/gud.el.gz > ~/.emacs.d/gud.el
+;; or
+;; M-x find-function gdb RET
+;; C-x C-w ~/.emacs.d/gud.el RET
+;; Patch it
+;; patch ~/.emacs.d/gud.el < 0001-Initial-Guile-REPL-guiler-debugger-support-for-GUD.patch
+;; M-x load-library ~/.emacs.d/gud.el RET
+;; M-x guiler RET
+;; ,m gud-break
+;; ,br main
+;; (main)
+;; ,n
+;; ,n # no easy RET shortcut yet
+;;
+;; And see |> marker in Emac's left margin track the program's execution.
+
+(read-set! keywords 'prefix)
+
+(define (main . args)
+  (eval '(main (command-line)) (resolve-module '(gud-break
+
+(define-module (gud-break)
+  :export (main))
+
+(define (stderr fmt . args)
+  (apply format (cons (current-error-port) (cons* fmt args)))
+  (force-output (current-error-port)))
+
+(define (main . args) 
+  (stderr "~a:hello world\n" (current-source-location))
+  (let
+  ((a #f)
+   (b #f))
+(set! a 1)
+(stderr "set: a=~a\n" a)
+(set! b 2)
+(stderr "set: b=~a\n" b)
+(let
+((c #f)
+ (d #f))
+  (set! c 3)
+  (stderr "set: c=~a\n" c)
+  (set! d 4)
+  (stderr "set: d=~a\n" d))
+(stderr "~a:leaving...\n" (current-source-location)))
+  (stderr "~a:goodbye world\n" (current-source-location)))
+
+
+
+
diff --git a/module/system/repl/command.scm b/module/system/repl/command.scm
index acb18e0..6be9ba3 100644
--- a/module/system/repl/command.scm
+++ b/module/system/repl/command.scm
@@ -735,7 +735,7 @@ Resume execution, breaking when the current frame finishes."
 Step until control reaches a different source location.
 
 Step until control reaches a different source location."
-  (let ((msg (format #f "Step into ~a" cur)))
+  (let ((msg (debug-prompt cur)))

[PATCH] Allow websocket over http by adding fallback.

2016-08-16 Thread Jan Nieuwenhuizen
Hi David,

Thanks for your websocket implementation!  Before actually using it I
found that I would like to use the nodejs (?) convention to reuse the
http socket for websocket traffic.

I found a way for websockets to share the http socket, see attached
patch; it requires some duplication of (web server) because it lacks
hooks for such use.

What do you think, would you like to help clean this up on the Guile
side?

Greetings,
Jan

>From 1d4cead12c0451ef1d35a1610701aa010f82aa03 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Tue, 16 Aug 2016 16:59:21 +0200
Subject: [PATCH] Allow websocket over http by adding fallback.

* web/socket/server.scm (serve-client): Add optional parameter FALLBACK.
(run-socket-server): Likewise.  Rename from (run-socket).  Allows use of ((web
server) run-server).
* test.scm: Update caller.
* test-http+ws.scm: New file.
* README: Mention ws over http example.
---
 README|  11 +-
 test-http+ws.scm  | 107 ++
 test.scm  |   2 +-
 web/socket/server.scm |  96 +++-
 4 files changed, 170 insertions(+), 46 deletions(-)
 create mode 100644 test-http+ws.scm

diff --git a/README b/README
index 181a537..ba77386 100644
--- a/README
+++ b/README
@@ -11,5 +11,14 @@ Run the example server:
   GUILE_LOAD_PATH="$PWD:$GUILE_LOAD_PATH" guile test.scm
 #+END_SRC
 
-Then, open the =text.html= page in your web browser.  If everything
+Then, open the =test.html= page in your web browser.  If everything
 works, "!ereht ,olleH" will be written to the JavaScript console.
+
+Run example http+websocket server:
+
+#+BEGIN_SRC sh
+  GUILE_LOAD_PATH="$PWD:$GUILE_LOAD_PATH" guile test-http+ws.scm
+#+END_SRC
+
+Then, visit [[http://localhost:9090][http:u//localhost:9090]] in your web browser.  If everything
+works, "!ereht ,olleH" will be printed as a greeting on the web page.
diff --git a/test-http+ws.scm b/test-http+ws.scm
new file mode 100644
index 000..4279318
--- /dev/null
+++ b/test-http+ws.scm
@@ -0,0 +1,107 @@
+(use-modules (ice-9 optargs)
+ (web http)
+ (web request)
+ (web response)
+ (web server)
+ (web server http)
+ (web socket server)
+ (web uri))
+
+;; Respond to text messages by reversing the message.  Respond to
+;; binary messages with "hello".
+(define (ws-handler data)
+  (if (string? data)
+  (string-reverse data)
+  "WS:hello"))
+
+(define (not-found request)
+  (format (current-error-port) "not found: ~S\n" (request-path-components request))
+  (values (build-response #:code 404)
+	  (string-append "Resource not found: "
+			 (uri->string (request-uri request)
+
+(define (http-handler request body)
+  (let ((components (map string->symbol (request-path-components request
+(cond
+ ((null? components)
+  (format (current-error-port) "serving index.html\n")
+  (values '((content-type . (text/html)))
+  "
+
+
+ var ws_url = 'ws://' + window.location.host;
+ var ws = new WebSocket (ws_url);
+ console.log ('initialized websocket');
+ ws.onmessage = function (evt) {
+ console.log ('received message');
+ console.log (evt.data);
+ var response = document.getElementById ('response');
+ response.innerHTML = evt.data;
+ };
+ ws.onopen = function () {
+ console.log ('connected');
+ ws.send ('Hello, there!');
+ }
+ ws.onclose = function () {
+ console.log ('closed websocket');
+ }
+
+
+
+Hi
+
+
+
+"))
+ (else
+  (not-found request)
+
+;; FIXME: extracted from ((web server) serve-one-client
+;; what about STATE?
+(define (handle-one-http-request handler impl server client request state)
+  ;;(debug-elapsed 'read-client)
+  (when client
+  (let ((body (read-request-body request)))
+   (call-with-values
+   (lambda ()
+ (handle-request handler request body state))
+ (lambda (response body state)
+   ;;(debug-elapsed 'handle-request)
+   (write-client impl server client response body)
+   ;;(debug-elapsed 'write-client)
+   state)))
+  state))
+
+(when (equal? (effective-version) "2.0")
+  (module-define! (current-module) 'make-server-impl (@@ (web server) make-server-impl))
+  (module-define! (current-module) 'server-impl-open (@@ (web server) server-impl-open))
+  (module-define! (current-module) 'server-impl-read (@@ (web server) server-impl-read))
+  (module-define! (current-module) 'server-impl-write (@@ (web server) server-impl-write))
+  (module-define! (current-module) 'server-impl-close (@@ (web server) server-impl-close)))
+
+(define* (open-http #:optional (ho

[PATCH] tests-suite: resurrect invoking check-guile --coverage.

2016-06-28 Thread Jan Nieuwenhuizen
Hi!

I'm sending this patch mainly because running the tests with coverage
fails.  I am using a patched copy (more gnu style error messages, that
patch did not get in yet) of the guile test framework and this is broken
with master now.

After this patch, try:

check-guile --coverage

Greetings,
Jan

>From dc55bda8314aca5a77b25d0b7521e907a98ee368 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Tue, 28 Jun 2016 15:16:13 +0200
Subject: [PATCH] tests-suite: resurrect invoking check-guile --coverage.

* test-suite/guile-test (main): remove (the-vm) from with-code-coverage call.
---
 test-suite/guile-test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test-suite/guile-test b/test-suite/guile-test
index 4a264b4..da1bcda 100755
--- a/test-suite/guile-test
+++ b/test-suite/guile-test
@@ -246,7 +246,7 @@
  tests
 (if (opt 'coverage #f)
 (let-values (((coverage-data _)
-  (with-code-coverage (the-vm) run-tests)))
+  (with-code-coverage run-tests)))
   (let ((out (open-output-file "guile.info")))
 (coverage-data->lcov coverage-data out)
 (close out)))
-- 
2.8.4


-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  


Re: Two people try to get lilypond for 2.0.12, but hit a roadblock

2016-05-12 Thread Jan Nieuwenhuizen
Arne Babenhauserheide writes:


> I just found out that there are currently three people who try to get
> lilypond to work with guile 2.0.12, but they hit a roadblock on the
> guile-side:
>
> http://lists.gnu.org/archive/html/lilypond-devel/2016-04/msg00063.html

Thanks.  I recently created a patch set for LilyPond to make configure
use guile-2.0.pc/guile-2.2.pc files -- that should take care of the
configure thing.  Just sent a reply to the lilypond-devel list.

Having guile-2.0 and 2.2 play nice when installed alongside eachother
could make testing with both versions a bit easier and possibly help
this go forward a bit.

Greetings,
Jan

-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



Re: anyone define port types?

2016-03-30 Thread Jan Nieuwenhuizen
Panicz Maciej Godek writes:

> I also used GOOPS, which I regret to this day, and so the
> whole framework needs a serious rewrite

What is it that you do not like about GOOPS?  I have a project that may
be in the same position.  I used GOOPS initially, then rewrote it to use
either GOOPS, plain lists or records backends.

When I kind of decided to go for plain lists, I discovered people (eg,
guix) are using records; and meanwhile Andy has made GOOPS perform.  Now
I'm thinking: if you only use GOOPS as a friendlier way to create
records, that may be nice after all.  Just wondering.

Greetings,
Jan

-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



Re: [PATCH] Append effective version to GUILE_LOAD[_COMPILED]_PATH

2016-03-19 Thread Jan Nieuwenhuizen
Mikael Djurfeldt writes:

> In python, the version number is higher up in the directory hierarchy,
> which, hypothetically, allows newer versions to have "inventions" in
> the more detailed directory structure:
>
> /usr/lib/python2.6
> /usr/lib/python2.7
> etc
>
> Just a thought.

Python's case is a bit different

 * Python does not look at any environment variable to boot

in contrast, setting GUILE_LOAD_*PATH to the wrong place makes Guile
barf trying to load eval.* or boot-9.*.  Also, guix by default sets
GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH, thus "ensuring" that
different guile major versions will fail to boot.

Do we want Guile to look at environment variables to find its core
libraries?

 * Python has magic numbers and skip/recompiles if a .py[oc] does
   not match

This resembles what Ludovic suggested and what I have submitted a patch
for, to skip invalid .go files.

Greetings, Jan

--
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl



Re: [PATCH v4] Skip invalid compiled file found, continue searching path.

2016-03-14 Thread Jan Nieuwenhuizen
Jan Nieuwenhuizen writes:

The previous version v3 works for skipping modules after guile
has booted, this v4 also handles skipping any wrong `eval.go'.

I have included some error feedback when you set

GUILE_DEBUG_GO=1

mainly to inspect and review the functionality, I suggest to get all
that out again.

Greetings,
Jan

>From 515d23b52baacc62bebdf5986292303596674d16 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Fri, 11 Mar 2016 14:58:09 +0100
Subject: [PATCH] Skip invalid compiled file found, continue searching path.

* libguile/vm.c (scm_load_compiled_with_vm): Add argument
  FALSE_ON_ERROR.
* libguile/loader.c (load_thunk_from_memory, scm_load_thunk_from_file,
  map_file_contents): Idem.
* libguile/load.c (search_path): Take optional output argument
  PATH_REMAINING.
  (scm_primitive_load_path): Use it.  Take optional argument
  LOAD_COMPILED_PATH.  Skip any invalid compiled file found and
  continue searching scm_loc_load_compiled_path.
  (internal_scm_init_eval_in_scheme): New function.  Implementation
  of scm_init_eval_in_scheme, taking path parameter to implement
  skipping any invalid eval.go's in path.
  (scm_init_eval_in_scheme): Use it.
---
 libguile/load.c   | 107 --
 libguile/loader.c |  42 +
 libguile/loader.h |   2 +-
 libguile/vm.c |   8 ++--
 libguile/vm.h |   2 +-
 5 files changed, 122 insertions(+), 39 deletions(-)

diff --git a/libguile/load.c b/libguile/load.c
index d26f9fc..b9db988 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -582,12 +582,15 @@ compiled_is_fresh (SCM full_filename, SCM compiled_filename,
file name that we find in the path.  Otherwise only return a file if
it is newer than SOURCE_STAT_BUF, otherwise issuing a warning if we
see a stale file earlier in the path, setting *FOUND_STALE_FILE to 1.
-  */
+
+   If PATH_REMAINING is not NULL, it is set to the tail of PATH that was
+   not skipped.  */
 static SCM
 search_path (SCM path, SCM filename, SCM extensions, SCM require_exts,
  struct stat *stat_buf,
  SCM source_file_name, struct stat *source_stat_buf,
- int *found_stale_file)
+ int *found_stale_file,
+ SCM *path_remaining)
 {
   struct stringbuf buf;
   char *filename_chars;
@@ -724,6 +727,8 @@ search_path (SCM path, SCM filename, SCM extensions, SCM require_exts,
 
  end:
   scm_dynwind_end ();
+  if (path_remaining)
+*path_remaining = path;
   return result;
 }
 
@@ -781,7 +786,7 @@ SCM_DEFINE (scm_search_path, "search-path", 2, 0, 1,
 require_exts = SCM_BOOL_F;
 
   return search_path (path, filename, extensions, require_exts, _buf,
-  SCM_BOOL_F, NULL, NULL);
+  SCM_BOOL_F, NULL, NULL, NULL);
 }
 #undef FUNC_NAME
 
@@ -806,7 +811,7 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0,
   SCM_VALIDATE_STRING (1, filename);
 
   return search_path (*scm_loc_load_path, filename, *scm_loc_load_extensions,
-  SCM_BOOL_F, _buf, SCM_BOOL_F, NULL, NULL);
+  SCM_BOOL_F, _buf, SCM_BOOL_F, NULL, NULL, NULL);
 }
 #undef FUNC_NAME
 
@@ -969,14 +974,19 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
 "depending on the optional second argument,\n"
 "@var{exception_on_not_found}.  If it is @code{#f}, @code{#f}\n"
 "will be returned.  If it is a procedure, it will be called\n"
-"with no arguments.  Otherwise an error is signalled.")
+"with no arguments.  Otherwise an error is signalled."
+"If the optional third argument,\n"
+"@var{load_compiled_path} is given, use it to search for compiled files\n"
+"instead of @var{*scm_loc_load_compiled_path}.")
 #define FUNC_NAME s_scm_primitive_load_path
 {
   SCM filename, exception_on_not_found;
   SCM full_filename, compiled_filename;
   SCM hook = *scm_loc_load_hook;
   struct stat stat_source, stat_compiled;
+  SCM load_compiled_path;
   int found_stale_compiled_file = 0;
+  SCM load_compiled_path_remaining = SCM_EOL;
 
   if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook)))
 SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f",
@@ -988,21 +998,27 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
 	 single argument (the file name).  */
   filename = args;
   exception_on_not_found = SCM_UNDEFINED;
+  load_compiled_path = *scm_loc_load_compiled_path;
 }
   else
 {
-  /* Starting from 1.9, this function takes 1 required and 1 optional
-	 argument.  */
+  /* Starting from 1.9, this function takes 1 required and 1
+	 optional argument.
+
+ Starting from 2.1.2, this function takes 1 required and 2

Re: [PATCH v3] Skip invalid compiled file found, continue searching path.

2016-03-13 Thread Jan Nieuwenhuizen
Jan Nieuwenhuizen writes:

That was a copy of the old one again, here is the updated v3.

Jan


Only after rebuilding world, I found this morning that the previous
patch did not exactly work as intended.  Find version 3 of this patch
attached.

Instead of having scm_call_0 possibly throw and catching that in
vm.c:(scm_load_compiled_with_vm), now the FALSE_ON_ERROR flag is
propagated down to loader.c: (scm_load_thunk_from_file,
scm_load_thunk_from_memory, map_file_contents).

To test this, do something like

mkdir -p ~/broken/srfi
cp 
/gnu/store/b44k6wx7nxn0kh2kchlazgas2ybc576v-guile-2.0.11/lib/guile/2.0/ccache/srfi/srfi-98.go
 ~/broken/srfi
touch ~/broken/srfi/srfi-111.go
export GUILE_DEBUG_GO=1
touch ~/broken/srfi/*.go

meta/guile --no-auto-compile -s <(echo '
(set! %load-compiled-path
(cons (string-append (getenv "HOME") "/broken") %load-compiled-path))
(use-modules (srfi srfi-98))
(display (get-environment-variable "GUILE_DEBUG_GO"))
(newline)
')

meta/guile --no-auto-compile -s <(echo '
(set! %load-compiled-path
(cons (string-append (getenv "HOME") "/broken") %load-compiled-path))
(use-modules (srfi srfi-111))
(display box)
(newline)
')

>From f356b4dc8feef19fcab66967cd99575e6e96a4d5 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Fri, 11 Mar 2016 14:58:09 +0100
Subject: [PATCH] Skip invalid compiled file found, continue searching path.

* libguile/vm.c (scm_load_compiled_with_vm): Add argument
  FALSE_ON_ERROR.
* libguile/loader.c (load_thunk_from_memory, scm_load_thunk_from_file,
  map_file_contents): Idem.
* libguile/load.c (search_path): Take optional output argument
  PATH_REMAINING.
  (scm_primitive_load_path): Use it.  Take optional argument
  LOAD_COMPILED_PATH.  Skip any invalid compiled file found and
  continue searching scm_loc_load_compiled_path.
---
 libguile/load.c   | 72 ++-
 libguile/loader.c | 42 
 libguile/loader.h |  2 +-
 libguile/vm.c |  8 ---
 libguile/vm.h |  2 +-
 5 files changed, 90 insertions(+), 36 deletions(-)

diff --git a/libguile/load.c b/libguile/load.c
index d26f9fc..4c3ae86 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -582,12 +582,15 @@ compiled_is_fresh (SCM full_filename, SCM compiled_filename,
file name that we find in the path.  Otherwise only return a file if
it is newer than SOURCE_STAT_BUF, otherwise issuing a warning if we
see a stale file earlier in the path, setting *FOUND_STALE_FILE to 1.
-  */
+
+   If PATH_REMAINING is not NULL, it is set to the tail of PATH that was
+   not skipped.  */
 static SCM
 search_path (SCM path, SCM filename, SCM extensions, SCM require_exts,
  struct stat *stat_buf,
  SCM source_file_name, struct stat *source_stat_buf,
- int *found_stale_file)
+ int *found_stale_file,
+ SCM *path_remaining)
 {
   struct stringbuf buf;
   char *filename_chars;
@@ -724,6 +727,8 @@ search_path (SCM path, SCM filename, SCM extensions, SCM require_exts,
 
  end:
   scm_dynwind_end ();
+  if (path_remaining)
+*path_remaining = path;
   return result;
 }
 
@@ -781,7 +786,7 @@ SCM_DEFINE (scm_search_path, "search-path", 2, 0, 1,
 require_exts = SCM_BOOL_F;
 
   return search_path (path, filename, extensions, require_exts, _buf,
-  SCM_BOOL_F, NULL, NULL);
+  SCM_BOOL_F, NULL, NULL, NULL);
 }
 #undef FUNC_NAME
 
@@ -806,7 +811,7 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0,
   SCM_VALIDATE_STRING (1, filename);
 
   return search_path (*scm_loc_load_path, filename, *scm_loc_load_extensions,
-  SCM_BOOL_F, _buf, SCM_BOOL_F, NULL, NULL);
+  SCM_BOOL_F, _buf, SCM_BOOL_F, NULL, NULL, NULL);
 }
 #undef FUNC_NAME
 
@@ -969,14 +974,19 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
 "depending on the optional second argument,\n"
 "@var{exception_on_not_found}.  If it is @code{#f}, @code{#f}\n"
 "will be returned.  If it is a procedure, it will be called\n"
-"with no arguments.  Otherwise an error is signalled.")
+"with no arguments.  Otherwise an error is signalled."
+"If the optional third argument,\n"
+"@var{load_compiled_path} is given, use it to search for compiled files\n"
+"instead of @var{*scm_loc_load_compiled_path}.")
 #define FUNC_NAME s_scm_primitive_load_path
 {
   SCM filename, exception_on_not_found;
   SCM full_filename, compiled_filename;
   SCM hook = *scm_loc_load_hook;
   struct stat stat_source, stat_compiled;
+  SCM load_compiled_path;
   int found_stale_co

Re: [PATCH] Skip invalid compiled file found, continue searching path.

2016-03-13 Thread Jan Nieuwenhuizen
David Kastrup writes:

Hi David,

> Shouldn't we worry about switching _to_ guile-2.0 first?

Are you asking for help on this?

In any case, I am sure that running guix with nicely coexisting
guile-2.0, guile-2.0++ and guile-next versions can be of great help
here.

Greetings,
Jan

-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



[PATCH v3] Skip invalid compiled file found, continue searching path.

2016-03-13 Thread Jan Nieuwenhuizen
Hi,

Only after rebuilding world, I found this morning that the previous
patch did not exactly work as intended.  Find version 3 of this patch
attached.

Instead of having scm_call_0 possibly throw and catching that in
vm.c:(scm_load_compiled_with_vm), now the FALSE_ON_ERROR flag is
propagated down to loader.c: (scm_load_thunk_from_file,
scm_load_thunk_from_memory, map_file_contents).

To test this, do something like

mkdir -p ~/broken/srfi
cp 
/gnu/store/b44k6wx7nxn0kh2kchlazgas2ybc576v-guile-2.0.11/lib/guile/2.0/ccache/srfi/srfi-98.go
 ~/broken/srfi
touch ~/broken/srfi/srfi-111.go
export GUILE_DEBUG_GO=1
touch ~/broken/srfi/*.go

meta/guile --no-auto-compile -s <(echo '
(set! %load-compiled-path
  (cons (string-append (getenv "HOME") "/broken") %load-compiled-path))
(use-modules (srfi srfi-98))
(display (get-environment-variable "GUILE_DEBUG_GO"))
(newline)
')

meta/guile --no-auto-compile -s <(echo '
(set! %load-compiled-path
  (cons (string-append (getenv "HOME") "/broken") %load-compiled-path))
(use-modules (srfi srfi-111))
(display box)
(newline)
')

Now, on to backporting this to stable-2.0 and rebuilding world again,
twice.

Greetings,
Jan

>From f4f53b48c1d5ff42ecc66279c3b1cfcfb09d6757 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Fri, 11 Mar 2016 14:58:09 +0100
Subject: [PATCH] Skip invalid compiled file found, continue searching path.

* libguile/vm.c (load_compiled_with_vm_catch_handler,
  do_try_scm_call_0): New static function.
  (scm_load_compiled_with_vm): Use them to implement not throwing
  if new argument EXCEPTION_ON_NOT_FOUND_P is not SCM_BOOL_TRUE.
* libguile/load.c (search_path): Take optional output argument
  PATH_REMAINING.
  (scm_primitive_load_path): Use it.  Take optional argument
  LOAD_COMPILED_PATH.  Skip any invalid compiled file found and
  continue searching scm_loc_load_compiled_path.
---
 libguile/load.c | 55 ---
 libguile/vm.c   | 27 ---
 libguile/vm.h   |  2 +-
 3 files changed, 65 insertions(+), 19 deletions(-)

diff --git a/libguile/load.c b/libguile/load.c
index d26f9fc..a6b87cf 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -582,12 +582,16 @@ compiled_is_fresh (SCM full_filename, SCM compiled_filename,
file name that we find in the path.  Otherwise only return a file if
it is newer than SOURCE_STAT_BUF, otherwise issuing a warning if we
see a stale file earlier in the path, setting *FOUND_STALE_FILE to 1.
+
+   If PATH_REMAINING is not NULL, it is set to the part of PATH that was
+   not yet searched.
   */
 static SCM
 search_path (SCM path, SCM filename, SCM extensions, SCM require_exts,
  struct stat *stat_buf,
  SCM source_file_name, struct stat *source_stat_buf,
- int *found_stale_file)
+ int *found_stale_file,
+ SCM *path_remaining)
 {
   struct stringbuf buf;
   char *filename_chars;
@@ -724,6 +728,8 @@ search_path (SCM path, SCM filename, SCM extensions, SCM require_exts,
 
  end:
   scm_dynwind_end ();
+  if (path_remaining)
+path_remaining = 
   return result;
 }
 
@@ -781,7 +787,7 @@ SCM_DEFINE (scm_search_path, "search-path", 2, 0, 1,
 require_exts = SCM_BOOL_F;
 
   return search_path (path, filename, extensions, require_exts, _buf,
-  SCM_BOOL_F, NULL, NULL);
+  SCM_BOOL_F, NULL, NULL, NULL);
 }
 #undef FUNC_NAME
 
@@ -806,7 +812,7 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0,
   SCM_VALIDATE_STRING (1, filename);
 
   return search_path (*scm_loc_load_path, filename, *scm_loc_load_extensions,
-  SCM_BOOL_F, _buf, SCM_BOOL_F, NULL, NULL);
+  SCM_BOOL_F, _buf, SCM_BOOL_F, NULL, NULL, NULL);
 }
 #undef FUNC_NAME
 
@@ -969,14 +975,19 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
 "depending on the optional second argument,\n"
 "@var{exception_on_not_found}.  If it is @code{#f}, @code{#f}\n"
 "will be returned.  If it is a procedure, it will be called\n"
-"with no arguments.  Otherwise an error is signalled.")
+"with no arguments.  Otherwise an error is signalled."
+"If the optional third argument,\n"
+"@var{load_compiled_path} is given, use it to search for compiled files\n"
+"instead of @var{*scm_loc_load_compiled_path}.")
 #define FUNC_NAME s_scm_primitive_load_path
 {
   SCM filename, exception_on_not_found;
   SCM full_filename, compiled_filename;
   SCM hook = *scm_loc_load_hook;
   struct stat stat_source, stat_compiled;
+  SCM load_compiled_path;
   int found_stale_compiled_file = 0;
+  SCM load_compiled_path_remaining = SCM_EOL;
 

[PATCH] Skip invalid compiled file found, continue searching path.

2016-03-11 Thread Jan Nieuwenhuizen
Hi,

As per chat with Ludovic on #guile (thanks!) find attached another
approach to allow switching incrementally from guile-2.0 to guile-2.2:
any invalid compiled files are skipped and we continue searching the
GUILE_LOAD_COMPILED_PATH instead of throwing early.

Greetings,
Jan

>From f4f53b48c1d5ff42ecc66279c3b1cfcfb09d6757 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Fri, 11 Mar 2016 14:58:09 +0100
Subject: [PATCH] Skip invalid compiled file found, continue searching path.

* libguile/vm.c (load_compiled_with_vm_catch_handler,
  do_try_scm_call_0): New static function.
  (scm_load_compiled_with_vm): Use them to implement not throwing
  if new argument EXCEPTION_ON_NOT_FOUND_P is not SCM_BOOL_TRUE.
* libguile/load.c (search_path): Take optional output argument
  PATH_REMAINING.
  (scm_primitive_load_path): Use it.  Take optional argument
  LOAD_COMPILED_PATH.  Skip any invalid compiled file found and
  continue searching scm_loc_load_compiled_path.
---
 libguile/load.c | 55 ---
 libguile/vm.c   | 27 ---
 libguile/vm.h   |  2 +-
 3 files changed, 65 insertions(+), 19 deletions(-)

diff --git a/libguile/load.c b/libguile/load.c
index d26f9fc..a6b87cf 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -582,12 +582,16 @@ compiled_is_fresh (SCM full_filename, SCM compiled_filename,
file name that we find in the path.  Otherwise only return a file if
it is newer than SOURCE_STAT_BUF, otherwise issuing a warning if we
see a stale file earlier in the path, setting *FOUND_STALE_FILE to 1.
+
+   If PATH_REMAINING is not NULL, it is set to the part of PATH that was
+   not yet searched.
   */
 static SCM
 search_path (SCM path, SCM filename, SCM extensions, SCM require_exts,
  struct stat *stat_buf,
  SCM source_file_name, struct stat *source_stat_buf,
- int *found_stale_file)
+ int *found_stale_file,
+ SCM *path_remaining)
 {
   struct stringbuf buf;
   char *filename_chars;
@@ -724,6 +728,8 @@ search_path (SCM path, SCM filename, SCM extensions, SCM require_exts,
 
  end:
   scm_dynwind_end ();
+  if (path_remaining)
+path_remaining = 
   return result;
 }
 
@@ -781,7 +787,7 @@ SCM_DEFINE (scm_search_path, "search-path", 2, 0, 1,
 require_exts = SCM_BOOL_F;
 
   return search_path (path, filename, extensions, require_exts, _buf,
-  SCM_BOOL_F, NULL, NULL);
+  SCM_BOOL_F, NULL, NULL, NULL);
 }
 #undef FUNC_NAME
 
@@ -806,7 +812,7 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0,
   SCM_VALIDATE_STRING (1, filename);
 
   return search_path (*scm_loc_load_path, filename, *scm_loc_load_extensions,
-  SCM_BOOL_F, _buf, SCM_BOOL_F, NULL, NULL);
+  SCM_BOOL_F, _buf, SCM_BOOL_F, NULL, NULL, NULL);
 }
 #undef FUNC_NAME
 
@@ -969,14 +975,19 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
 "depending on the optional second argument,\n"
 "@var{exception_on_not_found}.  If it is @code{#f}, @code{#f}\n"
 "will be returned.  If it is a procedure, it will be called\n"
-"with no arguments.  Otherwise an error is signalled.")
+"with no arguments.  Otherwise an error is signalled."
+"If the optional third argument,\n"
+"@var{load_compiled_path} is given, use it to search for compiled files\n"
+"instead of @var{*scm_loc_load_compiled_path}.")
 #define FUNC_NAME s_scm_primitive_load_path
 {
   SCM filename, exception_on_not_found;
   SCM full_filename, compiled_filename;
   SCM hook = *scm_loc_load_hook;
   struct stat stat_source, stat_compiled;
+  SCM load_compiled_path;
   int found_stale_compiled_file = 0;
+  SCM load_compiled_path_remaining = SCM_EOL;
 
   if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook)))
 SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f",
@@ -988,21 +999,27 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
 	 single argument (the file name).  */
   filename = args;
   exception_on_not_found = SCM_UNDEFINED;
+  load_compiled_path = *scm_loc_load_compiled_path;
 }
   else
 {
-  /* Starting from 1.9, this function takes 1 required and 1 optional
-	 argument.  */
+  /* Starting from 1.9, this function takes 1 required and 1
+	 optional argument.
+
+ Starting from 2.1.2, this function takes 1 required and 2
+	 optional arguments.  */
   long len;
 
   SCM_VALIDATE_LIST_COPYLEN (SCM_ARG1, args, len);
-  if (len < 1 || len > 2)
+  if (len < 1 || len > 3)
 	scm_error_num_args_subr (FUNC_NAME);
 
   filename = SCM_CAR (args);
  

[PATCH] Append effective version to GUILE_LOAD[_COMPILED]_PATH

2016-03-04 Thread Jan Nieuwenhuizen
Hi,

I am running guile-2.0 and guile-2.2 alongside each other which is
causing me some pain*).

This is what bits of my GUILE_LOAD_COMPILED_PATH look like

/gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/lib/guile/2.2/ccache
--> 
/gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/lib/guile/2.2/ccache/ice-9/and-let-star.go

/gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site/2.2/
--> 
/gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site/2.2/os/process.go

If `/' is always used as the suffix of each path
element, and we/guix/packagers do not include that suffix in GUILE_*PATH
elements, then Guile can append effective-prefix and different major
Guile-versions can happily share the same GUILE_LOAD[_COMPILED]_PATH,
e.g., having


GUILE_LOAD_COMPILED_PATH=/gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site

then guile-2.0 would get (os process) from

/gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site + /2.0
--> 
/gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site/2.0/os/process.go

and guile-2.2 would read

/gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site + /2.2
--> 
/gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site/2.2/os/process.go

What do you think?  No more pain!  Find patch attached.

Greetings,
Jan


*) Some of my pain

My Debian host system has guile-2.0, guix depends on guile-2.0, guix's
LD script depends on guile-2.0, the guile bits of my project depend on
guile-2.2.

I have some scripts to make this situation almost bearable, but still I
regularly

cannot find a basic library

[1]13:53:25 janneke@janneke-ijzer:~
$ guile --no-auto-compile
GNU Guile 2.0.11
Copyright (C) 1995-2014 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (use-modules (os proccess))
While compiling expression:
ERROR: no code for module (os proccess)

or some guile script (guix) aborts

guix environment --ad-hoc ccache coreutils git guix emacs guile-next 
guile-next-lib
Throw without catch before boot:
Throw to key misc-error with args ("make_objcode_from_file" "bad header on 
object file: ~s" ("\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00") 
#f)Aborting.
Aborted

or linking breaks

g++ -Wall -std=c++11  -g -I. -I out/alarm.project/c++ -I 
check/alarm.project/   out/alarm.project/c++/main.o 
out/alarm.project/c++/Alarm.o out/alarm.project/c++/AlarmSystem.o 
out/alarm.project/c++/pump.o out/alarm.project/c++/runtime.o-lboost_system 
-lboost_coroutine -lboost_thread -lboost_context -pthread -o 
out/alarm.project/c++/test
collect2: error: ld terminated with signal 6 [Afgebroken]
Throw without catch before boot:
Aborting.

and then I juggle installed guile versions and/or manually modify
GUILE_LOAD_COMPILED_PATH.

>From 81c8b35752235aeb26058c0baadd0ea58046f640 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Thu, 3 Mar 2016 18:18:55 +0100
Subject: [PATCH] Append effective version to GUILE_LOAD[_COMPILED]_PATH
 elements.

* libguile/load.c (scm_path_append_effective_version): New function
  (scm_init_load_path): Use it.

* am/guilec (moddir,ccachedir): Use GUILE_EFFECTIVE_VERSION as prefix.
---
 am/guilec   |  4 ++--
 libguile/load.c | 27 ++-
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/am/guilec b/am/guilec
index 5ef07fa..fa2b5ba 100644
--- a/am/guilec
+++ b/am/guilec
@@ -3,9 +3,9 @@ GOBJECTS = $(SOURCES:%.scm=%.go) $(ELISP_SOURCES:%.el=%.go)
 
 GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat
 
-moddir = $(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)/$(modpath)
+moddir = $(pkgdatadir)/$(modpath)/$(GUILE_EFFECTIVE_VERSION)
 nobase_mod_DATA = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES)
-ccachedir = $(pkglibdir)/$(GUILE_EFFECTIVE_VERSION)/ccache/$(modpath)
+ccachedir = $(pkglibdir)/ccache/$(GUILE_EFFECTIVE_VERSION)/$(modpath)
 nobase_ccache_DATA = $(GOBJECTS)
 EXTRA_DIST = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES)
 ETAGS_ARGS = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES)
diff --git a/libguile/load.c b/libguile/load.c
index d26f9fc..055f3c4 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -1,5 +1,6 @@
 /* Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2004, 2006, 2008,
- *   2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+ *   2009, 2010, 2011, 2012, 2013, 2014, 2016 Free Software Foundation,
+ *   Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -312,6 +313,28 @@ scm_i_mirror_backslashes (char *p

Re: guile-json: simple alist to json

2016-02-23 Thread Jan Nieuwenhuizen
Aleix Conchillo Flaqué writes:

Hi Aleix,

> thanks for the patch! I have tried with guile 2.0.11 and it's giving me th
> ​e error at the end. I had zero time to fix it, but I believe it's 
> complaining because of this:
>
> scheme@(guile-user)> (symbol 'a)
> ERROR: In procedure string:
> ERROR: In procedure string: Wrong type (expecting character): a
>
> ​"a" is already a symbol.

Ouch.  Yes, I get that too...

I have been running this for quite some time but aparrently I prepared
patches and sent untested, "cleaned-up" code.  Sorry.

Please find a new patch set attached.

Greetings,
Jan

>From 518feb26237080a3af61eafa650f3452ac24 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Wed, 5 Aug 2015 08:21:13 +0200
Subject: [PATCH 1/2] builder: convert symbols to string.

* json/builder.scm (->string): New function.
* json/builder.scm (json-build-string): Use it.
---
 json/builder.scm | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/json/builder.scm b/json/builder.scm
index c725b19..f12dee8 100644
--- a/json/builder.scm
+++ b/json/builder.scm
@@ -1,6 +1,7 @@
 ;;; (json builder) --- Guile JSON implementation.
 
 ;; Copyright (C) 2013 Aleix Conchillo Flaque <aconchi...@gmail.com>
+;; Copyright (C) 2015 Jan Nieuwenhuizen <jann...@gnu.org>
 ;;
 ;; This file is part of guile-json.
 ;;
@@ -105,6 +106,12 @@
   (display (number->string (exact->inexact scm)) port)
   (display (number->string scm) port)))
 
+(define (->string x)
+  (cond ((char? x) (make-string 1 x))
+((number? x) (number->string x))
+((symbol? x) (symbol->string x))
+(else x)))
+
 (define (json-build-string scm port escape)
   (display "\"" port)
   (display
@@ -121,7 +128,7 @@
  ((#\ht) '(#\\ #\t))
  ((#\/) (if escape `(#\\ ,c) (list c)))
  (else (string->list (build-char-string c)
- (string->list scm
+ (string->list (->string scm)
port)
   (display "\"" port))
 
@@ -155,6 +162,7 @@
((eq? scm #nil) (json-build-null port))
((boolean? scm) (json-build-boolean scm port))
((number? scm) (json-build-number scm port))
+   ((symbol? scm) (json-build-string (symbol->string scm) port escape))
((string? scm) (json-build-string scm port escape))
((list? scm) (json-build-array scm port escape pretty level))
((hash-table? scm) (json-build-object scm port escape pretty level))
-- 
2.6.3

>From d45b1be0805bdabef65d9f8edad122ee5e9f07e0 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Sat, 13 Feb 2016 21:16:46 +0100
Subject: [PATCH 2/2] builder: build objects from alists.

* json/builder.scm (atom?): New function.
* json/builder.scm (json-alist?): New function.
* json/builder.scm (json-build-object): SCM is an alist.
* json/builder.scm (json-build): Use it to support building objects from both
  hash-tables and alists.
---
 json/builder.scm | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/json/builder.scm b/json/builder.scm
index f12dee8..e1339b2 100644
--- a/json/builder.scm
+++ b/json/builder.scm
@@ -1,7 +1,7 @@
 ;;; (json builder) --- Guile JSON implementation.
 
 ;; Copyright (C) 2013 Aleix Conchillo Flaque <aconchi...@gmail.com>
-;; Copyright (C) 2015 Jan Nieuwenhuizen <jann...@gnu.org>
+;; Copyright (C) 2015,2016 Jan Nieuwenhuizen <jann...@gnu.org>
 ;;
 ;; This file is part of guile-json.
 ;;
@@ -112,6 +112,17 @@
 ((symbol? x) (symbol->string x))
 (else x)))
 
+(define (atom? x)
+  (or (char? x) (number? x) (string? x) (symbol? x)))
+
+(define (json-alist? x)
+  (and (pair? x)
+   (let loop ((x x))
+ (or (null? x)
+ (null? (car x))
+ (and (pair? (car x)) (atom? (caar x))
+  (loop (cdr x)))
+
 (define (json-build-string scm port escape)
   (display "\"" port)
   (display
@@ -146,7 +157,7 @@
   (build-newline port pretty)
   (simple-format port "~A{" (indent-string pretty level))
   (build-newline port pretty)
-  (let ((pairs (hash-map->list cons scm)))
+  (let ((pairs scm))
 (unless (null? pairs)
   (build-object-pair (car pairs) port escape pretty (+ level 1))
   (for-each (lambda (p)
@@ -164,8 +175,10 @@
((number? scm) (json-build-number scm port))
((symbol? scm) (json-build-string (symbol->string scm) port escape))
((string? scm) (json-build-string scm port escape))
+   ((json-alist? scm) (json-build-object scm port escape pretty level))
((list? scm) (json-build-array scm port escape pretty level))
-   ((hash-table? scm) (json-build-object scm port escape pretty level))
+   ((hash-table? scm)
+(json-build-object (hash-map->list cons scm) port escape pretty level))
(else (throw 'json-invalid
 
 ;;
-- 
2.6.3



-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  


Re: What is needed in guildhall to include it in Guile?

2016-02-22 Thread Jan Nieuwenhuizen
Arne Babenhauserheide writes:

> Please tell me what’s missing in Guildhall, so I can implement it.

I would like every interesting Guile package as it is right now either
in Guildhall or packaged with Guile core.

Most notably, I would very much like to have something like the
functionality of (os process) / (run-with-pipe) in Guile itself.

Also, I think that Guix has some nice functions that would be
great to have split-off into a Guildhall package, e.g. substitute*
and others in guix/build/utils.scm.

Greetings, Jan

-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



guile-json: simple alist to json

2016-02-18 Thread Jan Nieuwenhuizen
Hi Aleix,

Attached are two patches to allow converting simple alists
to json, this removes the need for strings or hash-tables

scheme@(json)> (scm->json-string '((a . 1) (b . 2)))
$2 = "{\"a\" : 1,\"b\" : 2}"

Greetings, Jan

>From 1faa02421076eeb7d680c6d189dab0cd8c272f3b Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Wed, 5 Aug 2015 08:21:13 +0200
Subject: [PATCH 1/2] builder: convert symbols to string.

* json/builder.scm (->string): New function.
* json/builder.scm (json-build-string): Use it.
---
 json/builder.scm | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/json/builder.scm b/json/builder.scm
index c725b19..a4210bc 100644
--- a/json/builder.scm
+++ b/json/builder.scm
@@ -1,6 +1,7 @@
 ;;; (json builder) --- Guile JSON implementation.
 
 ;; Copyright (C) 2013 Aleix Conchillo Flaque <aconchi...@gmail.com>
+;; Copyright (C) 2015 Jan Nieuwenhuizen <jann...@gnu.org>
 ;;
 ;; This file is part of guile-json.
 ;;
@@ -105,6 +106,8 @@
   (display (number->string (exact->inexact scm)) port)
   (display (number->string scm) port)))
 
+(define (->string x) (if (symbol? x) (symbol->string x) x))
+
 (define (json-build-string scm port escape)
   (display "\"" port)
   (display
@@ -121,7 +124,7 @@
  ((#\ht) '(#\\ #\t))
  ((#\/) (if escape `(#\\ ,c) (list c)))
  (else (string->list (build-char-string c)
- (string->list scm
+ (string->list (->string scm)
port)
   (display "\"" port))
 
@@ -155,6 +158,7 @@
((eq? scm #nil) (json-build-null port))
((boolean? scm) (json-build-boolean scm port))
((number? scm) (json-build-number scm port))
+   ((symbol? scm) (json-build-string (symbol->string scm) port escape))
((string? scm) (json-build-string scm port escape))
((list? scm) (json-build-array scm port escape pretty level))
((hash-table? scm) (json-build-object scm port escape pretty level))
-- 
2.6.3

>From d1f0840acf6f5421d6d04a0f8be61c2108d7 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <jann...@gnu.org>
Date: Sat, 13 Feb 2016 21:16:46 +0100
Subject: [PATCH 2/2] builder: build objects from alists.

* json/builder.scm (atom?): New function.
* json/builder.scm (json-alist?): New function.
* json/builder.scm (json-build-object): SCM is an alist.
* json/builder.scm (json-build): Use it to support building objects from both
  hash-tables and alists.
---
 json/builder.scm | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/json/builder.scm b/json/builder.scm
index a4210bc..6b33008 100644
--- a/json/builder.scm
+++ b/json/builder.scm
@@ -1,7 +1,7 @@
 ;;; (json builder) --- Guile JSON implementation.
 
 ;; Copyright (C) 2013 Aleix Conchillo Flaque <aconchi...@gmail.com>
-;; Copyright (C) 2015 Jan Nieuwenhuizen <jann...@gnu.org>
+;; Copyright (C) 2015,2016 Jan Nieuwenhuizen <jann...@gnu.org>
 ;;
 ;; This file is part of guile-json.
 ;;
@@ -108,6 +108,16 @@
 
 (define (->string x) (if (symbol? x) (symbol->string x) x))
 
+(define (atom? x) (or (char? x) (number? x) (string? x) (symbol x)))
+
+(define (json-alist? x)
+  (and (pair? x)
+   (let loop ((x x))
+ (or (null? x)
+ (null? (car x))
+ (and (pair? (car x)) (atom? (caar x))
+  (loop (cdr x)))
+
 (define (json-build-string scm port escape)
   (display "\"" port)
   (display
@@ -142,7 +152,7 @@
   (build-newline port pretty)
   (simple-format port "~A{" (indent-string pretty level))
   (build-newline port pretty)
-  (let ((pairs (hash-map->list cons scm)))
+  (let ((pairs scm))
 (unless (null? pairs)
   (build-object-pair (car pairs) port escape pretty (+ level 1))
   (for-each (lambda (p)
@@ -160,8 +170,10 @@
((number? scm) (json-build-number scm port))
((symbol? scm) (json-build-string (symbol->string scm) port escape))
((string? scm) (json-build-string scm port escape))
+   ((json-alist? scm) (json-build-object scm port escape pretty level))
((list? scm) (json-build-array scm port escape pretty level))
-   ((hash-table? scm) (json-build-object scm port escape pretty level))
+   ((hash-table? scm)
+(json-build-object (hash-map->list cons scm) port escape pretty level))
(else (throw 'json-invalid
 
 ;;
-- 
2.6.3


-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  


Re: guile-gnome: devel branch - 5 patches - Prepare 2.16.3

2015-08-17 Thread Jan Nieuwenhuizen
David Pirotte writes:

Great timing, I just return from vacation

 This is you last chance to make comments, I will merge, tag and release very 
 soon
 now.

I trust you have seen

https://lists.gnu.org/archive/html/guile-gtk-general/2014-07/threads.html

I could do with some feedback to get this integrated.

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



Re: [PATCH] Avoid GOOPS in (system foreign-object)?

2015-05-23 Thread Jan Nieuwenhuizen
Ludovic Courtès writes:

   time for i in `seq 1 30` ; do guile -c '(use-modules (oop goops))' ; done

Have you looked at --and tried this with-- Wingo's wip-goops-refactor
branch?  I just did and although I found some minor problems,
performance is amazing.

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



Re: Musings on performance, 2.2 and GOOPS (found factor 30)

2015-05-23 Thread Jan Nieuwenhuizen
Jan Nieuwenhuizen writes:

 I have an application of about 10.000 LOC using Guile/GOOPS with
 performance problems.  I found a way (thanks Ludo!) to run it with
 and without GOOPS, and gained a factor of 30 in performance.  See
 details below.

I just found out about Andy's wip-goops-refactor branch.  Using that
gives me almost the same benefit (only 15-20% slower), without any of
the modifications that I made over the past two weeks.

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



Musings on performance, 2.2 and GOOPS (found factor 30)

2015-05-17 Thread Jan Nieuwenhuizen
  0.00  0.05  0.00  language/cps/prune-bailouts.scm:48:0:prune-bailouts*
  0.00  0.05  0.00  oop/goops/dispatch.scm:238:0:cache-miss
  0.00  0.05  0.00  language/cps/simplify.scm:38:4:visit-cont
  0.00  0.05  0.00  oop/goops/dispatch.scm:267:0:memoize-method!
  0.00  0.05  0.00  module/gaiag/gom/util.scm:331:0
  0.00  0.03  0.00  ice-9/psyntax.scm:1474:6:expand-macro
  0.00  0.03  0.00  language/tree-il/compile-cps.scm:208:2:convert-arg
  0.00  0.03  0.00  module/gaiag/resolve.scm:167:2:event-or-function?
  0.00  0.03  0.00  module/gaiag/gom/util.scm:337:0
  0.00  0.03  0.00  language/cps/prune-bailouts.scm:100:0:prune-bailouts
  0.00  0.03  0.00  language/cps/contification.scm:404:0:contify
  0.00  0.03  0.00  ice-9/psyntax.scm:2206:26
  0.00  0.03  0.00  language/cps/dfg.scm:177:0:find-prompts
  0.00  0.03  0.00  language/cps/types.scm:235:0:var-min
  0.00  0.03  0.00  language/cps/slot-allocation.scm:613:16
  0.00  0.03  0.00  
language/cps/effects-analysis.scm:454:0:compute-effects
  0.00  0.03  0.00  language/cps/prune-bailouts.scm:89:2:visit-fun
  0.00  0.03  0.00  system/vm/assembler.scm:2024:0:link-debug
  0.00  0.03  0.00  language/tree-il/compile-cps.scm:559:0:build-subst
  0.00  0.03  0.00  ice-9/psyntax.scm:1363:12
  0.00  0.03  0.00  ice-9/psyntax.scm:986:6:distinct-bound-ids?
  0.00  0.03  0.00  
language/cps/contification.scm:41:0:compute-contification
  0.00  0.03  0.00  ice-9/psyntax.scm:1438:28
  0.00  0.03  0.00  
language/cps/slot-allocation.scm:284:4:recompute-live-slots
  0.00  0.03  0.00  module/gaiag/resolve.scm:164:2:var?
  0.00  0.03  0.00  language/cps/dce.scm:122:30:clause-folder
  0.00  0.03  0.00  language/cps/dfg.scm:230:0:visit-prompt-control-flow
  0.00  0.03  0.00  module/gaiag/gom/util.scm:385:0
  0.00  0.03  0.00  language/cps/dfg.scm:201:0:find-prompt-bodies
  0.00  0.03  0.00  ice-9/psyntax.scm:1725:8:check
  0.00  0.03  0.00  system/vm/assembler.scm:1165:0:make-object
  0.00  0.03  0.00  language/cps/slot-allocation.scm:326:4:parallel-move
  0.00  0.03  0.00  language/cps/dce.scm:273:34
  0.00  0.03  0.00  language/cps/constructors.scm:96:2:visit-fun
  0.00  0.03  0.00  srfi/srfi-1.scm:947:0:lset-adjoin
  0.00  0.03  0.00  system/vm/linker.scm:453:0:add-elf-objects
  0.00  0.03  0.00  module/gaiag/gom/util.scm:395:8
  0.00  0.02  0.00  language/cps/intmap.scm:210:0:intmap-union
  0.00  0.02  0.00  module/gaiag/gom/util.scm:469:12
  0.00  0.02  0.00  language/cps/dfg.scm:834:0:find-defining-expression
  0.00  0.02  0.00  system/vm/linker.scm:581:0:record-special-segments
  0.00  0.02  0.00  system/vm/linker.scm:443:10
  0.00  0.02  0.00  module/gaiag/gom/util.scm:398:8
  0.00  0.02  0.00  language/cps/type-fold.scm:285:22:clause-folder
  0.00  0.02  0.00  %initialize-object
  0.00  0.02  0.00  module/gaiag/gom/util.scm:461:12
  0.00  0.02  0.00  module/gaiag/gom/util.scm:458:8
  0.00  0.02  0.00  module/gaiag/gom/util.scm:467:0
  0.00  0.02  0.00  ice-9/psyntax.scm:267:4
  0.00  0.02  0.00  module/gaiag/gom/util.scm:411:0
  0.00  0.02  0.00  module/gaiag/resolve.scm:126:0
  0.00  0.02  0.00  system/vm/assembler.scm:1213:0:link-data
  0.00  0.02  0.00  ice-9/psyntax.scm:1887:8:parse-body
  0.00  0.02  0.00  current input:8:9
  0.00  0.02  0.00  oop/goops/dispatch.scm:217:0:cache-dispatch
  0.00  0.02  0.00  language/cps/types.scm:233:0:var-type
  0.00  0.02  0.00  srfi/srfi-1.scm:835:0:any1
  0.00  0.02  0.00  system/vm/elf.scm:819:0:string-table-ref
  0.00  0.02  0.00  language/cps/type-fold.scm:346:4:visit-cont
  0.00  0.02  0.00  ice-9/boot-9.scm:797:2:catch
  0.00  0.02  0.00  system/vm/assembler.scm:413:0:make-assembler
  0.00  0.02  0.00  language/cps/intset.scm:463:0:intset-subtract
  0.00  0.02  0.00  language/cps/intset.scm:108:0:add-level
  0.00  0.02  0.00  
language/cps/simplify.scm:36:0:compute-eta-reductions
  0.00  0.02  0.00  module/gaiag/gom/util.scm:299:0
  0.00  0.02  0.00  language/cps/renumber.scm:35:0:sort-conts
  0.00  0.02  0.00  ice-9/psyntax.scm:1438:28
  0.00  0.02  0.00  oop/goops/dispatch.scm:65:0:emit-linear-dispatch
  0.00  0.02  0.00  ice-9/psyntax.scm:1715:8:req
  0.00  0.02  0.00  module/gaiag/reader.scm:76:0:read-ast
  0.00  0.02  0.00  module/gaiag/gom/util.scm:443:0
---
Sample count: 494
Total time: 8.344575114 seconds (0.805487149 seconds in GC)


-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http

Re: [PATCH] Add GNU-style error location for failing tests in test-suite. v3

2014-12-07 Thread Jan Nieuwenhuizen
Mark H Weaver writes:

Hi Mark,

 Did you try running make check with this patch applied?

  I found that there were well over a hundred other uses of 'run-test'
 in the test-suite directory that you didn't update.

Ouch.

 Also, can you try to keep lines to 80 columns max?

Are those rethorical questions?

Find updated version attached.

Greetings, Jan.

From 322ebdc43806a95270fb98a1505d3fff49a3fce9 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen jann...@gnu.org
Date: Tue, 23 Sep 2014 18:37:44 +0200
Subject: [PATCH] Add GNU-style error location for failing tests in test-suite.

* test-suite/test-suite/lib.scm (run-test): Add location parameter;
  display GNU style error location for failing test.

* test-suite/test-suite/lib.scm (pass-if, pass-if-equal)
  (run-test-exception, pass-if-exception, expect-fail-exception): Update
  callers.

* test-suite/tests/getopt-long.test (pass-if-fatal-exception)
  test-suite/tests/goops.test (with-test-prefix)
  test-suite/tests/numbers.test (run-division-tests)
  test-suite/tests/r5rs_pitfall.test (should-be, should-be-but-isnt)
  test-suite/tests/srfi-64.test (guile-test-runner): Update callers.
---
 test-suite/test-suite/lib.scm  | 65 ++
 test-suite/tests/getopt-long.test  |  4 ++-
 test-suite/tests/goops.test|  1 +
 test-suite/tests/numbers.test  |  4 +--
 test-suite/tests/r5rs_pitfall.test | 14 
 test-suite/tests/srfi-64.test  | 14 +---
 6 files changed, 60 insertions(+), 42 deletions(-)

diff --git a/test-suite/test-suite/lib.scm b/test-suite/test-suite/lib.scm
index 27620a7..76a5820 100644
--- a/test-suite/test-suite/lib.scm
+++ b/test-suite/test-suite/lib.scm
@@ -80,16 +80,17 @@

  CORE FUNCTIONS
 
- The function (run-test name expected-result thunk) is the heart of the
- testing environment.  The first parameter NAME is a unique name for the
- test to be executed (for an explanation of this parameter see below under
- TEST NAMES).  The second parameter EXPECTED-RESULT is a boolean value
- that indicates whether the corresponding test is expected to pass.  If
- EXPECTED-RESULT is #t the test is expected to pass, if EXPECTED-RESULT is
- #f the test is expected to fail.  Finally, THUNK is the function that
- actually performs the test.  For example:
-
-(run-test integer addition #t (lambda () (= 2 (+ 1 1
+ The function (run-test name location expected-result thunk) is the heart
+ of the testing environment.  The first parameter NAME is a unique name
+ for the test to be executed (for an explanation of this parameter see
+ below under TEST NAMES).  The third parameter EXPECTED-RESULT is a
+ boolean value that indicates whether the corresponding test is expected
+ to pass.  If EXPECTED-RESULT is #t the test is expected to pass, if
+ EXPECTED-RESULT is #f the test is expected to fail.  Finally, THUNK is
+ the function that actually performs the test.  For example:
+
+(run-test integer addition (current-source-location) #t (lambda ()
+(= 2 (+ 1 1
 
  To report success, THUNK should either return #t or throw 'pass.  To
  report failure, THUNK should either return #f or throw 'fail.  If THUNK
@@ -107,9 +108,9 @@
  Convenience macros for tests expected to pass or fail
 
  * (pass-if name body) is a short form for
-   (run-test name #t (lambda () body))
+   (run-test name (current-source-location) #t (lambda () body))
  * (expect-fail name body) is a short form for
-   (run-test name #f (lambda () body))
+   (run-test name (current-source-location) #f (lambda () body))
 
  For example:
 
@@ -162,9 +163,9 @@
  a test name in such cases.
 
  * (pass-if expression) is a short form for
-   (run-test 'expression #t (lambda () expression))
+   (run-test 'expression location #t (lambda () expression))
  * (expect-fail expression) is a short form for
-   (run-test 'expression #f (lambda () expression))
+   (run-test 'expression location #f (lambda () expression))
 
  For example:
 
@@ -320,7 +321,7 @@
 ;;; The idea is taken from Greg, the GNUstep regression test environment.
 (define run-test
   (let ((test-running #f))
-(lambda (name expect-pass thunk)
+(lambda (name location expect-pass thunk)
   (if test-running
   (error Nested calls to run-test are not permitted.))
   (let ((test-name (full-name name)))
@@ -334,20 +335,21 @@
   (lambda (key . args)
 (case key
   ((pass)
-   (report (if expect-pass 'pass 'upass) test-name))
+   (report (if expect-pass 'pass 'upass) test-name location))
   ((fail)
;; ARGS may contain extra info about the failure,
;; such as the expected and actual value.
(apply report (if expect-pass 'fail

Re: [PATCH] Add GNU-style error location for failing tests in test-suite. v2

2014-10-05 Thread Jan Nieuwenhuizen
Jan Nieuwenhuizen writes:

Hi,

New version adds

* test-suite/tests/srfi-64.test (guile-test-runner): Update callers.

Thanks to Mark Weaver, who also suggested this function might better be
moved to test-suite/lib.scm.

Greetings,
Jan

PS: please have a look at my GUD and Guile-Gnome patches?


From ccf525b93d49be51611c5c9d69f0c17d77b60147 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen jann...@gnu.org
Date: Tue, 23 Sep 2014 18:37:44 +0200
Subject: [PATCH] Add GNU-style error location for failing tests in test-suite.

2014-10-05  Jan Nieuwenhuizen  jann...@gnu.org

	* test-suite/test-suite/lib.scm (run-test): Add location parameter;
display GNU style error location for failing test.

	* test-suite/test-suite/lib.scm (pass-if, pass-if-equal)
	(run-test-exception, pass-if-exception, expect-fail-exception):
	Update callers.

	* test-suite/tests/srfi-64.test (guile-test-runner): update callers.
---
 test-suite/test-suite/lib.scm | 45 +++
 test-suite/tests/srfi-64.test | 14 +-
 2 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/test-suite/test-suite/lib.scm b/test-suite/test-suite/lib.scm
index 9ecaf89..7bd3260 100644
--- a/test-suite/test-suite/lib.scm
+++ b/test-suite/test-suite/lib.scm
@@ -77,16 +77,16 @@
 
  CORE FUNCTIONS
 
- The function (run-test name expected-result thunk) is the heart of the
+ The function (run-test name location expected-result thunk) is the heart of the
  testing environment.  The first parameter NAME is a unique name for the
  test to be executed (for an explanation of this parameter see below under
- TEST NAMES).  The second parameter EXPECTED-RESULT is a boolean value
+ TEST NAMES).  The third parameter EXPECTED-RESULT is a boolean value
  that indicates whether the corresponding test is expected to pass.  If
  EXPECTED-RESULT is #t the test is expected to pass, if EXPECTED-RESULT is
  #f the test is expected to fail.  Finally, THUNK is the function that
  actually performs the test.  For example:
 
-(run-test integer addition #t (lambda () (= 2 (+ 1 1
+(run-test integer addition (current-source-location) #t (lambda () (= 2 (+ 1 1
 
  To report success, THUNK should either return #t or throw 'pass.  To
  report failure, THUNK should either return #f or throw 'fail.  If THUNK
@@ -104,9 +104,9 @@
  Convenience macros for tests expected to pass or fail
 
  * (pass-if name body) is a short form for
-   (run-test name #t (lambda () body))
+   (run-test name (current-source-location) #t (lambda () body))
  * (expect-fail name body) is a short form for
-   (run-test name #f (lambda () body))
+   (run-test name (current-source-location) #f (lambda () body))
 
  For example:
 
@@ -159,9 +159,9 @@
  a test name in such cases.
 
  * (pass-if expression) is a short form for
-   (run-test 'expression #t (lambda () expression))
+   (run-test 'expression location #t (lambda () expression))
  * (expect-fail expression) is a short form for
-   (run-test 'expression #f (lambda () expression))
+   (run-test 'expression location #f (lambda () expression))
 
  For example:
 
@@ -317,7 +317,7 @@
 ;;; The idea is taken from Greg, the GNUstep regression test environment.
 (define run-test
   (let ((test-running #f))
-(lambda (name expect-pass thunk)
+(lambda (name location expect-pass thunk)
   (if test-running
   (error Nested calls to run-test are not permitted.))
   (let ((test-name (full-name name)))
@@ -331,20 +331,21 @@
   (lambda (key . args)
 (case key
   ((pass)
-   (report (if expect-pass 'pass 'upass) test-name))
+   (report (if expect-pass 'pass 'upass) test-name location))
   ((fail)
;; ARGS may contain extra info about the failure,
;; such as the expected and actual value.
(apply report (if expect-pass 'fail 'xfail)
   test-name
+  location
   args))
   ((unresolved untested unsupported)
-   (report key test-name))
+   (report key test-name location))
   ((quit)
-   (report 'unresolved test-name)
+   (report 'unresolved test-name location)
(quit))
   (else
-   (report 'error test-name (cons key args))
+   (report 'error test-name location (cons key args))
 (set! test-running #f)
 
 ;;; A short form for tests that are expected to pass, taken from Greg.
@@ -353,9 +354,9 @@
 ((_ name)
  ;; presume this is a simple test, i.e. (pass-if (even? 2))
  ;; where the body should also be the name

[PATCH] test-suite: show backtrace when exception is thrown during test.

2014-10-05 Thread Jan Nieuwenhuizen
Hi,

I found that when code under test throws an exception, it is hidden from
the user.  The test suite niftily uses exceptions for message passing, I
wonder if this is wise (in-band signaling?).

Anyway, if an unexpected exception occurs I find it helpful to see the
backtrace.  See attached patch.

Greetings, Jan

From a11e28037d3d5d14d01df38f1dfae6e176bb3dd8 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen jann...@gnu.org
Date: Sun, 5 Oct 2014 11:42:09 +0200
Subject: [PATCH] test-suite: show backtrace when exception is thrown during
 test.

2014-10-05  Jan Nieuwenhuizen  jann...@gnu.org

	* test-suite/test-suite/lib.scm (run-test): Show backtrace for
	unexpected, i.e., non test-result carrying exceptions.
---
 test-suite/test-suite/lib.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test-suite/test-suite/lib.scm b/test-suite/test-suite/lib.scm
index 7bd3260..b17e910 100644
--- a/test-suite/test-suite/lib.scm
+++ b/test-suite/test-suite/lib.scm
@@ -345,7 +345,8 @@
(report 'unresolved test-name location)
(quit))
   (else
-   (report 'error test-name location (cons key args))
+   (report 'error test-name location (cons key args))
+   (backtrace)
 (set! test-running #f)
 
 ;;; A short form for tests that are expected to pass, taken from Greg.
-- 
/home/janneke/.signature


-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  


Re: Bison-like source locations in LALR-parser -- upstream update

2014-10-05 Thread Jan Nieuwenhuizen
Ludovic Courtès writes:

Hi,

 I don’t think this is needed.  Lexers are expected to use
 ‘make-lexical-token’ and ‘make-source-location’ from (system base lalr)
 to preserve source location information.

 I hope you're right...and that's what I tried, but I didn't get it
 working.  Possibly I need to cook-up a small example.

 Here’s an example:

 http://git.savannah.gnu.org/cgit/guile-rpc.git/tree/modules/rpc/compiler/lexer.l

Thanks for the example!  To me that is still a nice hack and that is why
I think that more straightforward bison-like parser support would be
nice.

 Yes...that's looks quit dead.  Isn't it?  I can try though...

 Well, that’s because it’s “finished.”  :-)

Heheh, yeah right ;-)

 But yeah, it’s worth trying.  Dominique has been responsive and helpful
 in the past.

Dominique was indeed very responsive and helpful.  He expressed that he
found my patches very interesting, found two problems, suggested how
to fix those and merged them.

Find attached the three patches pulled verbatim from upstream that Guile
is behind on now, the first one is by Dominique.

Greetings, Jan

From a6aac9d20d9d64f475780b59011c1e7e0cb1670a Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen jann...@gnu.org
Date: Sun, 5 Oct 2014 12:07:03 +0200
Subject: [PATCH 1/3] LALR-parser: No more unexpected shift-reduce conflicts
 with LR driver.

---
 module/system/base/lalr.upstream.scm | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/module/system/base/lalr.upstream.scm b/module/system/base/lalr.upstream.scm
index 217c439..ecc0fb3 100755
--- a/module/system/base/lalr.upstream.scm
+++ b/module/system/base/lalr.upstream.scm
@@ -235,6 +235,11 @@
 
   (define driver-name 'lr-driver)
 
+  (define (glr-driver?)
+(eq? driver-name 'glr-driver))
+  (define (lr-driver?)
+(eq? driver-name 'lr-driver))
+
   (define (gen-tables! tokens gram )
 (initialize-all)
 (rewrite-grammar
@@ -1097,14 +1102,14 @@
 			  (add-conflict-message
 			   %% Reduce/Reduce conflict (reduce  (- new-action) , reduce  (- current-action) 
 			   ) on ' (get-symbol (+ symbol nvars)) ' in state  state)
-			  (if (eq? driver-name 'glr-driver)
+			  (if (glr-driver?)
 			  (set-cdr! (cdr actions) (cons new-action (cddr actions)))
 			  (set-car! (cdr actions) (max current-action new-action
 			;; --- shift/reduce conflict
 			;; can we resolve the conflict using precedences?
 			(case (resolve-conflict symbol (- current-action))
 			  ;; -- shift
-			  ((shift)   (if (eq? driver-name 'glr-driver)
+			  ((shift)   (if (glr-driver?)
 	 (set-cdr! (cdr actions) (cons new-action (cddr actions)))
 	 (set-car! (cdr actions) new-action)))
 			  ;; -- reduce
@@ -1113,11 +1118,12 @@
 			  (else  (add-conflict-message
   %% Shift/Reduce conflict (shift  new-action , reduce  (- current-action)
   ) on ' (get-symbol (+ symbol nvars)) ' in state  state)
- (if (eq? driver-name 'glr-driver)
+ (if (glr-driver?)
 	 (set-cdr! (cdr actions) (cons new-action (cddr actions)))
 	 (set-car! (cdr actions) new-action
   
-	(vector-set! action-table state (cons (list symbol new-action) state-actions)
+	(vector-set! action-table state (cons (list symbol new-action) state-actions)))
+	))
 
 (define (add-action-for-all-terminals state action)
   (do ((i 1 (+ i 1)))
@@ -1131,7 +1137,9 @@
   (let ((red (vector-ref reduction-table i)))
 	(if (and red (= (red-nreds red) 1))
 	(if (and (= (red-nreds red) 1) (vector-ref consistent i))
-		(add-action-for-all-terminals i (- (car (red-rules red
+		(if (glr-driver?)
+		(add-action-for-all-terminals i (- (car (red-rules red
+		(add-action i 'default (- (car (red-rules red)
 		(let ((k (vector-ref lookaheads (+ i 1
 		  (let loop ((j (vector-ref lookaheads i)))
 		(if ( j k)
-- 
/home/janneke/.signature

From ddbbc3874bfdcefa23622edc16175c9881342194 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen jann...@gnu.org
Date: Sun, 5 Oct 2014 12:08:24 +0200
Subject: [PATCH 2/3] LALR-parser: provide bison-like location constructs @1
 ... @n.

* module/system/base/lalr.upstream.scm (lalr-parser): Provide
bison-like positional location constructs: @1 ... @n.
(*lalr-scm-version*): Bump to 2.5.0.
---
 module/system/base/lalr.upstream.scm | 40 
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/module/system/base/lalr.upstream.scm b/module/system/base/lalr.upstream.scm
index ecc0fb3..8e915f9 100755
--- a/module/system/base/lalr.upstream.scm
+++ b/module/system/base/lalr.upstream.scm
@@ -1,6 +1,7 @@
 ;;;
  An Efficient and Portable LALR(1) Parser Generator for Scheme
 ;;;
+;; Copyright 2014  Jan Nieuwenhuizen jann...@gnu.org
 ;; Copyright 1993, 2010 Dominique Boucher
 ;;
 ;; This program is free software: you can redistribute it and/or
@@ -17,7 +18,7 @@
 ;; along with this program.  If not, see http

Re: [PATCH] Add GNU-style error location for failing tests in test-suite. v3

2014-10-05 Thread Jan Nieuwenhuizen
Jan Nieuwenhuizen writes:

Changes in v3:

  * fix source-line/user-source-line confusion in srfi-64
  * better conforming commit message

From 2776b305b1b81ccebbb94ae4ef83ae83996a5253 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen jann...@gnu.org
Date: Tue, 23 Sep 2014 18:37:44 +0200
Subject: [PATCH] Add GNU-style error location for failing tests in test-suite.

* test-suite/test-suite/lib.scm (run-test): Add location parameter;
  display GNU style error location for failing test.

* test-suite/test-suite/lib.scm (pass-if, pass-if-equal)
  (run-test-exception, pass-if-exception, expect-fail-exception): Update
  callers.

* test-suite/tests/srfi-64.test (guile-test-runner): Update callers.
---
 test-suite/test-suite/lib.scm | 45 +++
 test-suite/tests/srfi-64.test | 14 +-
 2 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/test-suite/test-suite/lib.scm b/test-suite/test-suite/lib.scm
index 9ecaf89..7bd3260 100644
--- a/test-suite/test-suite/lib.scm
+++ b/test-suite/test-suite/lib.scm
@@ -77,16 +77,16 @@

  CORE FUNCTIONS
 
- The function (run-test name expected-result thunk) is the heart of the
+ The function (run-test name location expected-result thunk) is the heart of the
  testing environment.  The first parameter NAME is a unique name for the
  test to be executed (for an explanation of this parameter see below under
- TEST NAMES).  The second parameter EXPECTED-RESULT is a boolean value
+ TEST NAMES).  The third parameter EXPECTED-RESULT is a boolean value
  that indicates whether the corresponding test is expected to pass.  If
  EXPECTED-RESULT is #t the test is expected to pass, if EXPECTED-RESULT is
  #f the test is expected to fail.  Finally, THUNK is the function that
  actually performs the test.  For example:
 
-(run-test integer addition #t (lambda () (= 2 (+ 1 1
+(run-test integer addition (current-source-location) #t (lambda () (= 2 (+ 1 1
 
  To report success, THUNK should either return #t or throw 'pass.  To
  report failure, THUNK should either return #f or throw 'fail.  If THUNK
@@ -104,9 +104,9 @@
  Convenience macros for tests expected to pass or fail
 
  * (pass-if name body) is a short form for
-   (run-test name #t (lambda () body))
+   (run-test name (current-source-location) #t (lambda () body))
  * (expect-fail name body) is a short form for
-   (run-test name #f (lambda () body))
+   (run-test name (current-source-location) #f (lambda () body))
 
  For example:
 
@@ -159,9 +159,9 @@
  a test name in such cases.
 
  * (pass-if expression) is a short form for
-   (run-test 'expression #t (lambda () expression))
+   (run-test 'expression location #t (lambda () expression))
  * (expect-fail expression) is a short form for
-   (run-test 'expression #f (lambda () expression))
+   (run-test 'expression location #f (lambda () expression))
 
  For example:
 
@@ -317,7 +317,7 @@
 ;;; The idea is taken from Greg, the GNUstep regression test environment.
 (define run-test
   (let ((test-running #f))
-(lambda (name expect-pass thunk)
+(lambda (name location expect-pass thunk)
   (if test-running
   (error Nested calls to run-test are not permitted.))
   (let ((test-name (full-name name)))
@@ -331,20 +331,21 @@
   (lambda (key . args)
 (case key
   ((pass)
-   (report (if expect-pass 'pass 'upass) test-name))
+   (report (if expect-pass 'pass 'upass) test-name location))
   ((fail)
;; ARGS may contain extra info about the failure,
;; such as the expected and actual value.
(apply report (if expect-pass 'fail 'xfail)
   test-name
+  location
   args))
   ((unresolved untested unsupported)
-   (report key test-name))
+   (report key test-name location))
   ((quit)
-   (report 'unresolved test-name)
+   (report 'unresolved test-name location)
(quit))
   (else
-   (report 'error test-name (cons key args))
+   (report 'error test-name location (cons key args))
 (set! test-running #f)
 
 ;;; A short form for tests that are expected to pass, taken from Greg.
@@ -353,9 +354,9 @@
 ((_ name)
  ;; presume this is a simple test, i.e. (pass-if (even? 2))
  ;; where the body should also be the name.
- (run-test 'name #t (lambda () name)))
+ (run-test 'name (current-source-location) #t (lambda () name)))
 ((_ name rest ...)
- (run-test name #t (lambda () rest ...)
+ (run-test name (current-source

[PATCH] Add GNU-style error location for failing tests in test-suite.

2014-09-23 Thread Jan Nieuwenhuizen
Hi,

I am using the test-suite for my project and found that doing TDD it is
very helpful if Emacs jumps automatically to the failing tests'
location.

Patch attached.  What do you think?

Greetings, Jan

From efce4fa4be1c9bc6e368193b82b7eaa9b9957fee Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen jann...@gnu.org
Date: Tue, 23 Sep 2014 18:37:44 +0200
Subject: [PATCH] Add GNU-style error location for failing tests in test-suite.

2014-09-23  Jan Nieuwenhuizen  jann...@gnu.org

	* test-suite/test-suite/lib.scm (run-test): Add location parameter;
display GNU style error location for failing test.

	* test-suite/test-suite/lib.scm (pass-if, pass-if-equal)
	(run-test-exception, pass-if-exception, expect-fail-exception):
	Update callers.
---
 test-suite/test-suite/lib.scm | 45 +++
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/test-suite/test-suite/lib.scm b/test-suite/test-suite/lib.scm
index 9ecaf89..7bd3260 100644
--- a/test-suite/test-suite/lib.scm
+++ b/test-suite/test-suite/lib.scm
@@ -77,16 +77,16 @@
 
  CORE FUNCTIONS
 
- The function (run-test name expected-result thunk) is the heart of the
+ The function (run-test name location expected-result thunk) is the heart of the
  testing environment.  The first parameter NAME is a unique name for the
  test to be executed (for an explanation of this parameter see below under
- TEST NAMES).  The second parameter EXPECTED-RESULT is a boolean value
+ TEST NAMES).  The third parameter EXPECTED-RESULT is a boolean value
  that indicates whether the corresponding test is expected to pass.  If
  EXPECTED-RESULT is #t the test is expected to pass, if EXPECTED-RESULT is
  #f the test is expected to fail.  Finally, THUNK is the function that
  actually performs the test.  For example:
 
-(run-test integer addition #t (lambda () (= 2 (+ 1 1
+(run-test integer addition (current-source-location) #t (lambda () (= 2 (+ 1 1
 
  To report success, THUNK should either return #t or throw 'pass.  To
  report failure, THUNK should either return #f or throw 'fail.  If THUNK
@@ -104,9 +104,9 @@
  Convenience macros for tests expected to pass or fail
 
  * (pass-if name body) is a short form for
-   (run-test name #t (lambda () body))
+   (run-test name (current-source-location) #t (lambda () body))
  * (expect-fail name body) is a short form for
-   (run-test name #f (lambda () body))
+   (run-test name (current-source-location) #f (lambda () body))
 
  For example:
 
@@ -159,9 +159,9 @@
  a test name in such cases.
 
  * (pass-if expression) is a short form for
-   (run-test 'expression #t (lambda () expression))
+   (run-test 'expression location #t (lambda () expression))
  * (expect-fail expression) is a short form for
-   (run-test 'expression #f (lambda () expression))
+   (run-test 'expression location #f (lambda () expression))
 
  For example:
 
@@ -317,7 +317,7 @@
 ;;; The idea is taken from Greg, the GNUstep regression test environment.
 (define run-test
   (let ((test-running #f))
-(lambda (name expect-pass thunk)
+(lambda (name location expect-pass thunk)
   (if test-running
   (error Nested calls to run-test are not permitted.))
   (let ((test-name (full-name name)))
@@ -331,20 +331,21 @@
   (lambda (key . args)
 (case key
   ((pass)
-   (report (if expect-pass 'pass 'upass) test-name))
+   (report (if expect-pass 'pass 'upass) test-name location))
   ((fail)
;; ARGS may contain extra info about the failure,
;; such as the expected and actual value.
(apply report (if expect-pass 'fail 'xfail)
   test-name
+  location
   args))
   ((unresolved untested unsupported)
-   (report key test-name))
+   (report key test-name location))
   ((quit)
-   (report 'unresolved test-name)
+   (report 'unresolved test-name location)
(quit))
   (else
-   (report 'error test-name (cons key args))
+   (report 'error test-name location (cons key args))
 (set! test-running #f)
 
 ;;; A short form for tests that are expected to pass, taken from Greg.
@@ -353,9 +354,9 @@
 ((_ name)
  ;; presume this is a simple test, i.e. (pass-if (even? 2))
  ;; where the body should also be the name.
- (run-test 'name #t (lambda () name)))
+ (run-test 'name (current-source-location) #t (lambda () name)))
 ((_ name rest ...)
- (run-test name #t (lambda () rest ...)
+ (run-test name (current-source

Re: Bison-like source locations in LALR-parser

2014-08-13 Thread Jan Nieuwenhuizen
Ludovic Courtès writes:

Hi Ludo,

 I don’t think this is needed.  Lexers are expected to use
 ‘make-lexical-token’ and ‘make-source-location’ from (system base lalr)
 to preserve source location information.

I hope you're right...and that's what I tried, but I didn't get it
working.  Possibly I need to cook-up a small example.

What I found was that, yes the LEXER has all it needs, but once you
get to construction rules in the parser; say

   (interface-spec
(interface Identifier lbrace type-list event-list optional-behaviour 
rbrace) : `(,$1 ,$2 ,$4 ,$5 ,$6))

all it sees is the values, i.e. strings of the tokens that the lexer
sees.  The lexer cannot hand tokens to the parser, AFAICS.

What my patches do, is that for elements in the list that I construct
above that support source-properties, including the list itself, the
source location is set transparently.

Sometimes that is not enough, and you can use

   @1 ... @n

to set the source location explicitly.

 Besides, note that lalr.upstream.scm is a copy of the upstream lalr-scm,
 hosted at http://code.google.com/p/lalr-scm/.

Yes...that's looks quit dead.  Isn't it?  I can try though...

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



Re: [PATCH] Support Guile backtraces in compilation mode.

2014-08-09 Thread Jan Nieuwenhuizen
Stefan Monnier writes:

 +* Guile backtraces

 Please add the Guile version here (ideally, the latest version known to
 generate such backtraces).

Done, latest is 2.0.11

 +(guile-file ^In \\(.+\\):\n 1)

 AFAICT this will mark those lines as errors (aka red) whereas I think
 these should be marked as supplemental info (aka green).

Yes, I have raised this question for the new backtrace format.  

I do not care too much which we choose, however the usual case is that
there is only one backtrace and having them red makes stepping with
next-error,previous-error easier for me.

 Other than that, it looks OK, so if someone wants to install it,
 go ahead.

Thanks, updated version attached.
Greetings, Jan

From 7193c30c89868b27d610cd9cc7fa63136d4db44c Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen jann...@gnu.org
Date: Fri, 8 Aug 2014 10:24:44 +0200
Subject: [PATCH] Support Guile backtraces in compilation mode.

	* lisp/progmodes/compile.el (compilation-error-regexp-alist-alist):
	Add Guile regexpses.

	* etc/compilation.txt (file): Add Guile backtrace example.

	* test/automated/compile-tests.el (compile--test-error-line):
	Grok FILE being nil.  Allows for Guile tests to pass.
	(compile-tests--test-regexps-data): Add Guile tests.
---
 etc/ChangeLog   |  4 
 etc/compilation.txt | 20 
 lisp/ChangeLog  |  5 +
 lisp/progmodes/compile.el   |  2 ++
 test/ChangeLog  |  6 ++
 test/automated/compile-tests.el |  7 ++-
 6 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/etc/ChangeLog b/etc/ChangeLog
index c0db914..67a70e0 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
+2014-08-08  Jan Nieuwenhuizen  jann...@gnu.org
+
+	* compilation.txt (file): Add Guile backtrace example.
+
 2014-07-21  Dmitry Antipov  dmanti...@yandex.ru
 
 	* TODO: remove frame height remark.
diff --git a/etc/compilation.txt b/etc/compilation.txt
index e835c57..919e4db 100644
--- a/etc/compilation.txt
+++ b/etc/compilation.txt
@@ -261,6 +261,26 @@ file:G:/cygwin/dev/build-myproj.xml:54: Compiler Adapter 'javac' can't be found.
 {standard input}:27041: Warning: end of file not at end of a line; newline inserted
 
 
+* Guile backtrace, 2.0.11
+
+symbols: guile-file, guile-line
+
+Backtrace:
+In ice-9/boot-9.scm:
+ 157: 6 [catch #t #catch-closure 196e3e0 ...]
+In unknown file:
+   ?: 5 [apply-smob/1 #catch-closure 196e3e0]
+In ice-9/boot-9.scm:
+  63: 4 [call-with-prompt prompt0 ...]
+In ice-9/eval.scm:
+ 432: 3 [eval # #]
+In unknown file:
+   ?: 2 [eval (main (command-line)) #directory (gud-break) 1962510]
+In /home/janneke/vc/guile/examples/gud-break.scm:
+1038: 1 [main (gud-break.scm)]
+1033: 0 [stderr ~a:hello world\n (# # #)]
+
+
 * Lucid Compiler, lcc 3.x
 
 symbol: lcc
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b3da957..5ab9b40 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2014-08-08  Jan Nieuwenhuizen  jann...@gnu.org
+
+	* progmodes/compile.el (compilation-error-regexp-alist-alist):
+	Add Guile regexpses.
+
 2014-08-05  Jan Nieuwenhuizen  jann...@gnu.org
 
 	* progmodes/gud.el (guiler): New function.  Starts the Guile REPL;
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 000d719..5d3b687 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -477,6 +477,8 @@ File = \\(.+\\), Line = \\([0-9]+\\)\\(?:, Column = \\([0-9]+\\)\\)?
  ;;
  ^\\([^ \t\r\n(]+\\) (\\([0-9]+\\):\\([0-9]+\\)) 
  1 2 3)
+(guile-file ^In \\(.+\\):\n 1)
+(guile-line ^ *\\([0-9]+\\): *\\([0-9]+\\) nil 1 2)
 )
   Alist of values for `compilation-error-regexp-alist'.)
 
diff --git a/test/ChangeLog b/test/ChangeLog
index 4339dc5..92b0d12 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-08  Jan Nieuwenhuizen  jann...@gnu.org
+
+	* automated/compile-tests.el (compile--test-error-line): Grok FILE
+	being nil.  Allows for Guile tests to pass.
+	(compile-tests--test-regexps-data): Add Guile tests.
+
 2014-08-03  Glenn Morris  r...@gnu.org
 
 	* automated/Makefile.in (check-tar): New rule.
diff --git a/test/automated/compile-tests.el b/test/automated/compile-tests.el
index 6c169ee..e231331 100644
--- a/test/automated/compile-tests.el
+++ b/test/automated/compile-tests.el
@@ -190,6 +190,10 @@
  1 nil 54 G:/cygwin/dev/build-myproj.xml)
 ({standard input}:27041: Warning: end of file not at end of a line; newline inserted
  1 nil 27041 {standard input})
+;; Guile
+(In foo.scm:\n 1 nil nil foo.scm)
+(  63:4 [call-with-prompt prompt0 ...] 1 4 63 nil)
+(1038: 1 [main (\gud-break.scm\)] 1 1 1038 nil)
 ;; lcc
 (E, file.cc(35,52) Illegal operation on pointers 1 52 35 file.cc)
 (W, file.cc(36,52) blah blah 1 52 36 file.cc)
@@ -338,7 +342,8 @@ END-LINE, if that matched.)
 	(setq end-line (cdr line) line (car line)))
 	(and (equal (compilation--loc-col loc) col)
 	 (equal (compilation--loc-line loc

Re: [PATCH] Initial Guile REPL (guiler) debugger support for GUD.

2014-08-09 Thread Jan Nieuwenhuizen
Stefan Monnier writes:

  * progmodes/gud.el (guiler): New function.  Starts the Guile REPL;
  add Guile debugger support for GUD.

 Looks OK, 

That's great, we're going to guile support in GUD!

 tho please use the new `setq-local' when setting variables
 buffer-locally.

New patch attached.

Greetings, Jan

From 3db1acfeb281f6fbbc8df19164b7f313e37b81ee Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen jann...@gnu.org
Date: Mon, 4 Aug 2014 11:15:59 +0200
Subject: [PATCH] Initial Guile REPL (guiler) debugger support for GUD.

	* lisp/progmodes/gud.el (guiler): New function.  Starts the
	Guile REPL; add Guile debugger support for GUD.
---
 lisp/ChangeLog|  5 +++
 lisp/progmodes/gud.el | 89 ---
 2 files changed, 89 insertions(+), 5 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b6f16ea..b3da957 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2014-08-05  Jan Nieuwenhuizen  jann...@gnu.org
+
+	* progmodes/gud.el (guiler): New function.  Starts the Guile REPL;
+	add Guile debugger support for GUD.
+
 2014-08-03  Paul Eggert  egg...@cs.ucla.edu
 
 	Don't mishandle year- dates (Bug#18176).
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index c6fc944..09085f7 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -34,7 +34,8 @@
 ;; and added a menu. Brian D. Carlstrom b...@ai.mit.edu combined the IRIX
 ;; kluge with the gud-xdb-directories hack producing gud-dbx-directories.
 ;; Derek L. Davies ddav...@world.std.com added support for jdb (Java
-;; debugger.)
+;; debugger.)  Jan Nieuwenhuizen added support for the Guile REPL (Guile
+;; debugger).
 
 ;;; Code:
 
@@ -140,7 +141,7 @@ Used to gray out relevant toolbar icons.)
 			   (display-graphic-p)
 			   (fboundp 'x-show-tip))
 		  :visible (memq gud-minor-mode
-'(gdbmi dbx sdb xdb pdb))
+'(gdbmi guiler dbx sdb xdb pdb))
 	  :button (:toggle . gud-tooltip-mode))
 ([refresh]	Refresh . gud-refresh)
 ([run]	menu-item Run gud-run
@@ -170,11 +171,11 @@ Used to gray out relevant toolbar icons.)
 ([up]	menu-item Up Stack gud-up
 		  :enable (not gud-running)
 		  :visible (memq gud-minor-mode
- '(gdbmi gdb dbx xdb jdb pdb)))
+ '(gdbmi gdb guiler dbx xdb jdb pdb)))
 ([down]	menu-item Down Stack gud-down
 		  :enable (not gud-running)
 		  :visible (memq gud-minor-mode
- '(gdbmi gdb dbx xdb jdb pdb)))
+ '(gdbmi gdb guiler dbx xdb jdb pdb)))
 ([pp]	menu-item Print S-expression gud-pp
   :enable (and (not gud-running)
   (bound-and-true-p gdb-active-process))
@@ -195,7 +196,7 @@ Used to gray out relevant toolbar icons.)
 ([finish]	menu-item Finish Function gud-finish
   :enable (not gud-running)
 		  :visible (memq gud-minor-mode
- '(gdbmi gdb xdb jdb pdb)))
+ '(gdbmi gdb guiler xdb jdb pdb)))
 ([stepi]	menu-item Step Instruction gud-stepi
   :enable (not gud-running)
 		  :visible (memq gud-minor-mode '(gdbmi gdb dbx)))
@@ -1704,6 +1705,83 @@ and source-file directory for your debugger.
   (run-hooks 'pdb-mode-hook))

 ;; ==
+;; Guile REPL (guiler) functions
+
+;; History of argument lists passed to guiler.
+(defvar gud-guiler-history nil)
+
+(defvar gud-guiler-lastfile nil)
+
+(defun gud-guiler-marker-filter (string)
+  (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) string))
+
+  (let ((start 0))
+(while
+	(cond
+	 ((string-match ^In \\(.*\\): gud-marker-acc start)
+  (setq gud-guiler-lastfile (match-string 1 gud-marker-acc)))
+	 ((string-match ^\\([^:\n]+\\):\\([0-9]+\\):\\([0-9]+\\):[^\n]*
+			gud-marker-acc start)
+  (setq gud-guiler-lastfile (match-string 1 gud-marker-acc))
+  (setq gud-last-frame
+(cons gud-guiler-lastfile
+  (string-to-number (match-string 2 gud-marker-acc)
+	 ((string-match ^[ ]*\\([0-9]+\\):\\([0-9]+\\)  [^\n]*
+			gud-marker-acc start)
+  (if gud-guiler-lastfile
+  (setq gud-last-frame
+(cons gud-guiler-lastfile
+  (string-to-number (match-string 1 gud-marker-acc))
+	 ((string-match comint-prompt-regexp gud-marker-acc start) t)
+ ((string= (substring gud-marker-acc start) ) nil)
+ (t nil))
+  (setq start (match-end 0)))
+
+;; Search for the last incomplete line in this chunk
+(while (string-match \n gud-marker-acc start)
+  (setq start (match-end 0)))
+
+;; If we have an incomplete line, store it in gud-marker-acc.
+(setq gud-marker-acc (substring gud-marker-acc (or start 0
+  string)
+
+
+(defcustom gud-guiler-command-name guile
+  File name for executing the Guile debugger.
+This should be an executable on your path, or an absolute file name.
+  :type 'string
+  :group 'gud)
+
+;;;###autoload
+(defun guiler (command-line

compilation-mode support for Guile backtrace; v2 much simplified

2014-08-08 Thread Jan Nieuwenhuizen
Hi,

Here's a much simplified and collapsed version of compilation-mode
support for Guile backtraces.

In short: 
  -no resolving trickery of absolute file names, we'll try
   to do that upstream
  -remaining are the two non-GNU standard Guile convention regexpses

It would be nice we can have Guile-2.2 use GNU-standard error messages
in backtraces, but either way we'll probably have to live with current
guile backtraces for quite some time.

Greetings, Jan


-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



[PATCH] Support Guile backtraces in compilation mode.

2014-08-08 Thread Jan Nieuwenhuizen
* progmodes/compile.el (compilation-error-regexp-alist-alist):
Add Guile regexpses.

etc/: Add Guile backtrace example.

* compilation.txt (file): Add Guile backtrace example.

test/: Add tests for Guile compile regexps.

* automated/compile-tests.el (compile--test-error-line): Grok FILE
being nil.  Allows for Guile tests to pass.
(compile-tests--test-regexps-data): Add Guile tests.
---
 etc/ChangeLog   |  4 
 etc/compilation.txt | 18 ++
 lisp/ChangeLog  |  9 +
 lisp/progmodes/compile.el   |  2 ++
 test/ChangeLog  |  6 ++
 test/automated/compile-tests.el |  7 ++-
 6 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/etc/ChangeLog b/etc/ChangeLog
index c0db914..67a70e0 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
+2014-08-08  Jan Nieuwenhuizen  jann...@gnu.org
+
+   * compilation.txt (file): Add Guile backtrace example.
+
 2014-07-21  Dmitry Antipov  dmanti...@yandex.ru
 
* TODO: remove frame height remark.
diff --git a/etc/compilation.txt b/etc/compilation.txt
index e835c57..84da6b9 100644
--- a/etc/compilation.txt
+++ b/etc/compilation.txt
@@ -261,6 +261,24 @@ file:G:/cygwin/dev/build-myproj.xml:54: Compiler Adapter 
'javac' can't be found.
 {standard input}:27041: Warning: end of file not at end of a line; newline 
inserted
 
 
+* Guile backtraces
+
+Backtrace:
+In ice-9/boot-9.scm:
+ 157: 6 [catch #t #catch-closure 196e3e0 ...]
+In unknown file:
+   ?: 5 [apply-smob/1 #catch-closure 196e3e0]
+In ice-9/boot-9.scm:
+  63: 4 [call-with-prompt prompt0 ...]
+In ice-9/eval.scm:
+ 432: 3 [eval # #]
+In unknown file:
+   ?: 2 [eval (main (command-line)) #directory (gud-break) 1962510]
+In /home/janneke/vc/guile/examples/gud-break.scm:
+1038: 1 [main (gud-break.scm)]
+1033: 0 [stderr ~a:hello world\n (# # #)]
+
+
 * Lucid Compiler, lcc 3.x
 
 symbol: lcc
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b3da957..b66d48a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2014-08-08  Jan Nieuwenhuizen  jann...@gnu.org
+
+   * progmodes/compile.el (compilation-error-regexp-alist-alist):
+   Add Guile regexpses.
+   (compilation-dynamic-guile-load-path-p)
+   (compilation-guile-get-load-path-command)
+   (compilation-guile-load-path): New variable.
+   (compilation-guile-in-find-file): New function.
+
 2014-08-05  Jan Nieuwenhuizen  jann...@gnu.org
 
* progmodes/gud.el (guiler): New function.  Starts the Guile REPL;
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 000d719..5d3b687 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -477,6 +477,8 @@ File = \\(.+\\), Line = \\([0-9]+\\)\\(?:, Column = 
\\([0-9]+\\)\\)?
  ;;
  ^\\([^ \t\r\n(]+\\) (\\([0-9]+\\):\\([0-9]+\\)) 
  1 2 3)
+(guile-file ^In \\(.+\\):\n 1)
+(guile-line ^ *\\([0-9]+\\): *\\([0-9]+\\) nil 1 2)
 )
   Alist of values for `compilation-error-regexp-alist'.)
 
diff --git a/test/ChangeLog b/test/ChangeLog
index 4339dc5..92b0d12 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-08  Jan Nieuwenhuizen  jann...@gnu.org
+
+   * automated/compile-tests.el (compile--test-error-line): Grok FILE
+   being nil.  Allows for Guile tests to pass.
+   (compile-tests--test-regexps-data): Add Guile tests.
+
 2014-08-03  Glenn Morris  r...@gnu.org
 
* automated/Makefile.in (check-tar): New rule.
diff --git a/test/automated/compile-tests.el b/test/automated/compile-tests.el
index 6c169ee..e231331 100644
--- a/test/automated/compile-tests.el
+++ b/test/automated/compile-tests.el
@@ -190,6 +190,10 @@
  1 nil 54 G:/cygwin/dev/build-myproj.xml)
 ({standard input}:27041: Warning: end of file not at end of a line; 
newline inserted
  1 nil 27041 {standard input})
+;; Guile
+(In foo.scm:\n 1 nil nil foo.scm)
+(  63:4 [call-with-prompt prompt0 ...] 1 4 63 nil)
+(1038: 1 [main (\gud-break.scm\)] 1 1 1038 nil)
 ;; lcc
 (E, file.cc(35,52) Illegal operation on pointers 1 52 35 file.cc)
 (W, file.cc(36,52) blah blah 1 52 36 file.cc)
@@ -338,7 +342,8 @@ END-LINE, if that matched.)
(setq end-line (cdr line) line (car line)))
(and (equal (compilation--loc-col loc) col)
 (equal (compilation--loc-line loc) line)
-(equal (caar (compilation--loc-file-struct loc)) file)
+(or (not file) 
+ (equal (caar (compilation--loc-file-struct loc)) file))
 (or (null end-col)
 (equal (car (cadr (nth 2 (compilation--loc-file-struct loc
end-col))
-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




[PATCH] Use GNU standard for displaying backtraces. Allows Emacs integration.

2014-08-08 Thread Jan Nieuwenhuizen
* libguile/backtrace.c (display_backtrace_file_and_line): Return
absolute file name if not accessible from here.
(display_backtrace_file): Use GNU-standard error message; remove
In -prefix, add `:line:column' suffix.
---
 libguile/backtrace.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libguile/backtrace.c b/libguile/backtrace.c
index 0c0f110..3b004b6 100644
--- a/libguile/backtrace.c
+++ b/libguile/backtrace.c
@@ -319,16 +319,19 @@ display_backtrace_get_file_line (SCM frame, SCM *file, 
SCM *line)
 {
   /* (addr . (filename . (line . column))), from vm compilation */
   *file = scm_cadr (source);
+  if (scm_is_false (scm_stat (*file, SCM_BOOL_F)))
+{
+  SCM full = SCM_BOOL_F;
+  full = scm_sys_search_load_path (*file);
+  if (!scm_is_false (full))
+*file = full;
+}
   *line = scm_caddr (source);
 }
 }
 
 static void
-display_backtrace_file (frame, last_file, port, pstate)
- SCM frame;
- SCM *last_file;
- SCM port;
- scm_print_state *pstate;
+display_backtrace_file (SCM frame, SCM *last_file, SCM port, scm_print_state 
*pstate)
 {
   SCM file, line;
 
@@ -339,7 +342,6 @@ display_backtrace_file (frame, last_file, port, pstate)
 
   *last_file = file;
 
-  scm_puts_unlocked (In , port);
   if (scm_is_false (file))
 if (scm_is_false (line))
   scm_puts_unlocked (unknown file, port);
@@ -349,6 +351,8 @@ display_backtrace_file (frame, last_file, port, pstate)
 {
   pstate-writingp = 0;
   scm_iprin1 (file, port, pstate);
+  scm_puts_unlocked (:, port);
+  scm_intprint (scm_to_int (line) + 1, 10, port);
   pstate-writingp = 1;
 }
   scm_puts_unlocked (:\n, port);
-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




Use GNU standard for displaying backtraces?

2014-08-08 Thread Jan Nieuwenhuizen
Hi,

Trying to get Emacs's compilation-mode to support stepping down Guile
backtraces, I wrote some elisp code to determine the absolute file
name for incomplete relative files that come from Guile's load path,
e.g., ice/boot-9.scm.

Resolving this in Emacs is very difficult to do cleanly, if at all
possible.  Also, supporting other editors will have the same problem.
See: https://lists.gnu.org/archive/html/emacs-devel/2014-08/msg00137.html

That's why I propose to discuss this patch.  It changes the backtrace
output from

guile --debug -e main examples/gud-break.scm
Backtrace:
In ice-9/boot-9.scm:
 157: 6 [catch #t #catch-closure abe3e0 ...]
In unknown file:
   ?: 5 [apply-smob/1 #catch-closure abe3e0]
In ice-9/boot-9.scm:
  63: 4 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 432: 3 [eval # #]
In unknown file:
   ?: 2 [eval (main (command-line)) #directory (gud-break) ab2240]
In /home/janneke/vc/guile/examples/gud-break.scm:
1038: 1 [main (examples/gud-break.scm)]
1032: 0 [stderr ~a:hello world\n (# # #)]

/home/janneke/vc/guile/examples/gud-break.scm:1032:0: In procedure stderr:
/home/janneke/vc/guile/examples/gud-break.scm:1032:0: In procedure 
module-lookup: Unbound variable: o

to

~/guile-2.2/bin/guile --debug -e main examples/gud-break.scm
Backtrace:
unknown file:
   ?: 5 [apply-smob/1 #catch-closure b9bca0]
/home/janneke/guile-2.2/share/guile/2.2/ice-9/boot-9.scm:732:
 732: 4 [call-with-prompt #unbound #unbound ...]
/home/janneke/guile-2.2/share/guile/2.2/ice-9/eval.scm:527:
 527: 3 [eval _ #(#directory (guile-user) b892d0)]
unknown file:
   ?: 2 [eval (main (command-line)) #directory (gud-break) dc0360]
/home/janneke/vc/guile/examples/gud-break.scm:1038:
1038: 1 [main . _]
1032: 0 [stderr _ . _]

/home/janneke/vc/guile/examples/gud-break.scm:1032:0: In procedure stderr:
/home/janneke/vc/guile/examples/gud-break.scm:1032:0: In procedure 
module-lookup: Unbound variable: o

What do you think?

Stefan Monnier also suggests to postfix the backtrace line with `info',
something like

/home/janneke/vc/guile/examples/gud-break.scm:1038:info:
1038: 1 [main . _]
1032: 0 [stderr _ . _]

however, I like to step down all lines of a backtrace with
next-error/previous-error, so haven't done that.

Greetings, Jan


-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



Re: Initial GUD integration for Guile

2014-08-08 Thread Jan Nieuwenhuizen
Jan Nieuwenhuizen writes:

After chatting with davexunit and seeing a remark from Andy,
here's a somewhat less clueless version.

Worries about sources-alist, *last-source* etc remain...

Greetings, Jan

From 7ce14e739ba2ada7bc1e46a9821ae6c83871b14c Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen jann...@gnu.org
Date: Tue, 5 Aug 2014 12:34:09 +0200
Subject: [PATCH] Initial GUD integration support.

* examples/gud-break.scm: New example; showing initial GUD
integration.

* module/system/repl/debug.scm (debug-prompt): New procedure;
gdb-like debug prompt.  Experimental!

* module/system/repl/error-handling.scm (call-with-error-handling):
* module/system/repl/command.scm (step, step-instruction, next)
(next-instruction): Use it.
---
 examples/gud-break.scm| 56 +++
 module/system/repl/command.scm|  8 ++---
 module/system/repl/debug.scm  | 48 ++
 module/system/repl/error-handling.scm |  3 +-
 4 files changed, 110 insertions(+), 5 deletions(-)
 create mode 100644 examples/gud-break.scm

diff --git a/examples/gud-break.scm b/examples/gud-break.scm
new file mode 100644
index 000..8378a0c
--- /dev/null
+++ b/examples/gud-break.scm
@@ -0,0 +1,56 @@
+#! /bin/sh
+# -*-scheme-*-
+exec guile -e main -s $0 $@
+!#
+;; Experimental GUD support for Guile REPL
+;; Find a gud.el that you want to patch, e.g.
+;; zcat /usr/share/emacs/24.3/lisp/progmodes/gud.el.gz  ~/.emacs.d/gud.el
+;; or
+;; M-x find-function gdb RET
+;; C-x C-w ~/.emacs.d/gud.el RET
+;; Patch it
+;; patch ~/.emacs.d/gud.el  0001-Initial-Guile-REPL-guiler-debugger-support-for-GUD.patch
+;; M-x load-library ~/.emacs.d/gud.el RET
+;; M-x guiler RET
+;; ,m gud-break
+;; ,br main
+;; ,r
+;; ,n
+;; ,n # no easy RET shortcut yet
+;;
+;; And see | marker in Emac's left margin track the program's execution.
+
+(read-set! keywords 'prefix)
+
+(define (main . args)
+  (eval '(main (command-line)) (resolve-module '(gud-break
+
+(define-module (gud-break)
+  :export (main))
+
+(define (stderr fmt . args)
+  (apply format (cons (current-error-port) (cons* fmt args)))
+  (force-output (current-error-port)))
+
+(define (main . args) 
+  (stderr ~a:hello world\n (current-source-location))
+  (let
+  ((a #f)
+   (b #f))
+(set! a 1)
+(stderr set: a=~a\n a)
+(set! b 2)
+(stderr set: b=~a\n b)
+(let
+((c #f)
+ (d #f))
+  (set! c 3)
+  (stderr set: c=~a\n c)
+  (set! d 4)
+  (stderr set: d=~a\n d))
+(stderr ~a:leaving...\n (current-source-location)))
+  (stderr ~a:goodbye world\n (current-source-location)))
+
+
+
+
diff --git a/module/system/repl/command.scm b/module/system/repl/command.scm
index 62bc297..3999c5e 100644
--- a/module/system/repl/command.scm
+++ b/module/system/repl/command.scm
@@ -740,7 +740,7 @@ Resume execution, breaking when the current frame finishes.
 Step until control reaches a different source location.
 
 Step until control reaches a different source location.
-  (let ((msg (format #f Step into ~a cur)))
+  (let ((msg (debug-prompt cur)))
 (add-ephemeral-stepping-trap! cur (repl-next-resumer msg)
   #:into? #t #:instruction? #f)
 (throw 'quit)))
@@ -750,7 +750,7 @@ Step until control reaches a different source location.
 Step until control reaches a different instruction.
 
 Step until control reaches a different VM instruction.
-  (let ((msg (format #f Step into ~a cur)))
+  (let ((msg (debug-prompt cur)))
 (add-ephemeral-stepping-trap! cur (repl-next-resumer msg)
   #:into? #t #:instruction? #t)
 (throw 'quit)))
@@ -760,7 +760,7 @@ Step until control reaches a different VM instruction.
 Step until control reaches a different source location in the current frame.
 
 Step until control reaches a different source location in the current frame.
-  (let ((msg (format #f Step into ~a cur)))
+  (let ((msg (debug-prompt cur)))
 (add-ephemeral-stepping-trap! cur (repl-next-resumer msg)
   #:into? #f #:instruction? #f)
 (throw 'quit)))
@@ -770,7 +770,7 @@ Step until control reaches a different source location in the current frame.
 Step until control reaches a different instruction in the current frame.
 
 Step until control reaches a different VM instruction in the current frame.
-  (let ((msg (format #f Step into ~a cur)))
+  (let ((msg (debug-prompt cur)))
 (add-ephemeral-stepping-trap! cur (repl-next-resumer msg)
   #:into? #f #:instruction? #t)
 (throw 'quit)))
diff --git a/module/system/repl/debug.scm b/module/system/repl/debug.scm
index 300145d..c6b796d 100644
--- a/module/system/repl/debug.scm
+++ b/module/system/repl/debug.scm
@@ -24,6 +24,7 @@
   #:use-module (system base language)
   #:use-module (system vm vm)
   #:use-module (system vm frame)
+  #:use-module

[PATCH] Initial GUD integration support.

2014-08-05 Thread Jan Nieuwenhuizen
-vector narrow-stack-vector
@@ -160,6 +162,66 @@
 (lp (+ i inc)
 (frame-source frame)))
 
+(define *source-alist* '())
+(define (source-add file-name source)
+  (set! *source-alist* (assoc-set! *source-alist* file-name source))
+  source)
+
+(define* (gulp-port #:optional (port current-input-port)) 
+  (or (and-let* ((result (read-delimited  port))
+ ((string? result)))
+result)
+  ))
+
+(define (gulp-file file-name)
+  (gulp-port (open-input-file (format #f ~a file-name
+
+(define (read-source-file file-name)
+  (or (assoc-ref *source-alist* file-name)
+  (and-let* ((source (gulp-file file-name))
+ (lines (string-split source #\newline)))
+(source-add file-name lines
+
+(define (fs-find-file file-name)
+  (let loop ((path (cons . %load-path )))
+(if (null? path)
+#f
+(let* ((dir (car path)) 
+   (fs-file-name (string-join (list dir file-name) /)))
+  (if (file-exists? fs-file-name)
+  fs-file-name
+  (loop (cdr path)))
+
+(define (source-code file-name line-number)
+  (or (and-let* ((file-name file-name)
+ (line-number line-number)
+ (lines (read-source-file file-name)))
+(list-ref lines line-number))
+  ))
+
+(define *last-source* #f)
+(define* (debug-prompt frame #:optional (last-source *last-source*) (message 
))
+  A gdb,pydb-like debug prompt.
+  (define (source:pretty-file source)
+(if source
+(or (source:file source) current input)
+unknown file))
+  (let* ((source (frame-source frame))
+ (file (source:pretty-file source))
+ (file-name (fs-find-file file))
+ (line (and= source source:line))
+ (col (and= source source:column))
+ (code (source-code file-name line))
+ (line-column (format #f ~a~a (if line (1+ line) ) 
+  (if col (format #f :~a col) 
+(set! *last-source* source)
+(string-append
+ (if (and file (not (equal? file (source:pretty-file last-source
+ (format #f ~~a:~a:~a~ file-name line-column message) ;;GNU 
standard!
+ ;;(format #f ~In ~a:~a~ file-name message) ;;or awkward Guile 
convention?
+ )
+ (format #f ~~10a~a line-column code
+
 ;; Ideally here we would have something much more syntactic, in that a set! to 
a
 ;; local var that is not settable would raise an error, and export etc forms
 ;; would modify the module in question: but alack, this is what we have now.
diff --git a/module/system/repl/error-handling.scm 
b/module/system/repl/error-handling.scm
index 94a9f2a..1777854 100644
--- a/module/system/repl/error-handling.scm
+++ b/module/system/repl/error-handling.scm
@@ -80,7 +80,8 @@
(begin
  (format #t ~a~% error-msg)
  (format #t Entering a new prompt.  )
- (format #t Type `,bt' for a backtrace or `,q' to 
continue.\n)))
+ (format #t Type `,bt' for a backtrace or `,q' to 
continue.\n)
+ (format #t ~a~ (debug-prompt frame #f
((@ (system repl repl) start-repl) #:debug debug)
 
 (define (null-trap-handler frame trap-idx trap-name)
-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




[PATCH] Initial Guile REPL (guiler) debugger support for GUD.

2014-08-05 Thread Jan Nieuwenhuizen
* progmodes/gud.el (guiler): New function.  Starts the Guile REPL;
add Guile debugger support for GUD.
---
 lisp/ChangeLog|  5 +++
 lisp/progmodes/gud.el | 89 ---
 2 files changed, 89 insertions(+), 5 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b6f16ea..b3da957 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2014-08-05  Jan Nieuwenhuizen  jann...@gnu.org
+
+   * progmodes/gud.el (guiler): New function.  Starts the Guile REPL;
+   add Guile debugger support for GUD.
+
 2014-08-03  Paul Eggert  egg...@cs.ucla.edu
 
Don't mishandle year- dates (Bug#18176).
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index c6fc944..fd57e62 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -34,7 +34,8 @@
 ;; and added a menu. Brian D. Carlstrom b...@ai.mit.edu combined the IRIX
 ;; kluge with the gud-xdb-directories hack producing gud-dbx-directories.
 ;; Derek L. Davies ddav...@world.std.com added support for jdb (Java
-;; debugger.)
+;; debugger.)  Jan Nieuwenhuizen added support for the Guile REPL (Guile
+;; debugger).
 
 ;;; Code:
 
@@ -140,7 +141,7 @@ Used to gray out relevant toolbar icons.)
   (display-graphic-p)
   (fboundp 'x-show-tip))
  :visible (memq gud-minor-mode
-   '(gdbmi dbx sdb xdb pdb))
+   '(gdbmi guiler dbx sdb xdb pdb))
  :button (:toggle . gud-tooltip-mode))
 ([refresh] Refresh . gud-refresh)
 ([run] menu-item Run gud-run
@@ -170,11 +171,11 @@ Used to gray out relevant toolbar icons.)
 ([up]  menu-item Up Stack gud-up
  :enable (not gud-running)
  :visible (memq gud-minor-mode
-'(gdbmi gdb dbx xdb jdb pdb)))
+'(gdbmi gdb guiler dbx xdb jdb pdb)))
 ([down]menu-item Down Stack gud-down
  :enable (not gud-running)
  :visible (memq gud-minor-mode
-'(gdbmi gdb dbx xdb jdb pdb)))
+'(gdbmi gdb guiler dbx xdb jdb pdb)))
 ([pp]  menu-item Print S-expression gud-pp
   :enable (and (not gud-running)
  (bound-and-true-p gdb-active-process))
@@ -195,7 +196,7 @@ Used to gray out relevant toolbar icons.)
 ([finish]  menu-item Finish Function gud-finish
   :enable (not gud-running)
  :visible (memq gud-minor-mode
-'(gdbmi gdb xdb jdb pdb)))
+'(gdbmi gdb guiler xdb jdb pdb)))
 ([stepi]   menu-item Step Instruction gud-stepi
   :enable (not gud-running)
  :visible (memq gud-minor-mode '(gdbmi gdb dbx)))
@@ -1704,6 +1705,83 @@ and source-file directory for your debugger.
   (run-hooks 'pdb-mode-hook))
 
 ;; ==
+;; Guile REPL (guiler) functions
+
+;; History of argument lists passed to guiler.
+(defvar gud-guiler-history nil)
+
+(defvar gud-guiler-lastfile nil)
+
+(defun gud-guiler-marker-filter (string)
+  (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) 
string))
+
+  (let ((start 0))
+(while
+   (cond
+((string-match ^In \\(.*\\): gud-marker-acc start)
+  (setq gud-guiler-lastfile (match-string 1 gud-marker-acc)))
+((string-match ^\\([^:\n]+\\):\\([0-9]+\\):\\([0-9]+\\):[^\n]*
+   gud-marker-acc start)
+  (setq gud-guiler-lastfile (match-string 1 gud-marker-acc))
+  (setq gud-last-frame
+(cons gud-guiler-lastfile
+  (string-to-number (match-string 2 gud-marker-acc)
+((string-match ^[ ]*\\([0-9]+\\):\\([0-9]+\\)  [^\n]*
+   gud-marker-acc start)
+  (if gud-guiler-lastfile
+  (setq gud-last-frame
+(cons gud-guiler-lastfile
+  (string-to-number (match-string 1 
gud-marker-acc))
+((string-match comint-prompt-regexp gud-marker-acc start) t)
+ ((string= (substring gud-marker-acc start) ) nil)
+ (t nil))
+  (setq start (match-end 0)))
+
+;; Search for the last incomplete line in this chunk
+(while (string-match \n gud-marker-acc start)
+  (setq start (match-end 0)))
+
+;; If we have an incomplete line, store it in gud-marker-acc.
+(setq gud-marker-acc (substring gud-marker-acc (or start 0
+  string)
+
+
+(defcustom gud-guiler-command-name guile
+  File name for executing the Guile debugger.
+This should be an executable on your path, or an absolute file name.
+  :type 'string
+  :group 'gud)
+
+;;;###autoload
+(defun guiler (command-line)
+  Run guiler on program FILE in buffer

Bison-like source locations in LALR-parser

2014-08-02 Thread Jan Nieuwenhuizen
Hi,

I am using these patches to provide Bison-like source locations that we
need for error messages and the like.  The output of the parser is a
plain scheme tree, now transparently annotated with source locations
that match the parsed input file.

What do you think?

Greetings, Jan
-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




[PATCH 2/2] LALR-parser: transparent source locations using source-proprerties.

2014-08-02 Thread Jan Nieuwenhuizen
* module/system/base/lalr.upstream.scm (lalr-parser): Add
token argument to push.
(lr-driver): (___push): Transparently set source location from
token using source-properties.
---
 module/system/base/lalr.upstream.scm | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/module/system/base/lalr.upstream.scm 
b/module/system/base/lalr.upstream.scm
index b250c23..871c931 100755
--- a/module/system/base/lalr.upstream.scm
+++ b/module/system/base/lalr.upstream.scm
@@ -1609,7 +1609,10 @@
   '()))
,(if (= nt 0)
 '$1
-`(___push ,n ,nt ,(cdr p) ,@(if (eq? driver-name 
'lr-driver) '() '(___sp)
+`(___push ,n ,nt ,(cdr p) ,@(if (eq? driver-name 
'lr-driver) '() '(___sp)) 
+   ,(if (eq? driver-name 'lr-driver)
+   `(vector-ref ___stack 
(1+ ___sp))
+   `(list-ref ___sp (1+ 
___sp))
 
   gram/actions
 
@@ -1825,7 +1828,11 @@
 (if (= ___sp (vector-length ___stack))
 (___growstack)))
   
-  (define (___push delta new-category lvalue)
+  (define (___push delta new-category lvalue tok)
+(if (and (supports-source-properties? lvalue)
+ (not (source-property lvalue 'loc))
+ (lexical-token? tok))
+(set-source-property! lvalue 'loc (lexical-token-source tok)))
 (set! ___sp (- ___sp (* delta 2)))
 (let* ((state (vector-ref ___stack ___sp))
(new-state (cdr (assoc new-category (vector-ref ___gtable state)
@@ -2000,7 +2007,7 @@
 (set! *parses* (cons parse *parses*)))
 
 
-  (define (push delta new-category lvalue stack)
+  (define (push delta new-category lvalue stack tok)
 (let* ((stack (drop stack (* delta 2)))
(state (car stack))
(new-state (cdr (assv new-category (vector-ref ___gtable state)
-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




[PATCH 1/2] LALR-parser: provide bison-like location constructs @1 ... @n.

2014-08-02 Thread Jan Nieuwenhuizen
* module/system/base/lalr.upstream.scm (lalr-parser): Provide
bison-like positional location constructs: @1 ... @n.
(*lalr-scm-version*): Bump to 2.5.0.
---
 module/system/base/lalr.upstream.scm | 40 
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/module/system/base/lalr.upstream.scm 
b/module/system/base/lalr.upstream.scm
index 217c439..b250c23 100755
--- a/module/system/base/lalr.upstream.scm
+++ b/module/system/base/lalr.upstream.scm
@@ -1,6 +1,7 @@
 ;;;
  An Efficient and Portable LALR(1) Parser Generator for Scheme
 ;;;
+;; Copyright 2014  Jan Nieuwenhuizen jann...@gnu.org
 ;; Copyright 1993, 2010 Dominique Boucher
 ;;
 ;; This program is free software: you can redistribute it and/or
@@ -17,7 +18,7 @@
 ;; along with this program.  If not, see http://www.gnu.org/licenses/.
 
 
-(define *lalr-scm-version* 2.4.1)
+(define *lalr-scm-version* 2.5.0)
 
 
 (cond-expand 
@@ -1591,17 +1592,19 @@
 `(let* (,@(if act
   (let loop ((i 1) (l rhs))
 (if (pair? l)
-(let ((rest (cdr l)))
-  (cons 
-   `(,(string-symbol
-   (string-append
-$
-(number-string 
- (+ (- n i) 1
- ,(if (eq? driver-name 'lr-driver)
-  `(vector-ref ___stack (- 
___sp ,(- (* i 2) 1)))
-  `(list-ref ___sp ,(+ (* (- i 
1) 2) 1
-   (loop (+ i 1) rest)))
+(let ((rest (cdr l))
+   (ns (number-string (+ (- n i) 
1
+   (cons
+`(tok ,(if (eq? driver-name 
'lr-driver)
+   `(vector-ref ___stack 
(- ___sp ,(- (* i 2) 1)))
+   `(list-ref ___sp ,(+ (* 
(- i 1) 2) 1
+(cons
+ `(,(string-symbol (string-append 
$ ns))
+   (if (lexical-token? tok) 
(lexical-token-value tok) tok))
+ (cons
+  `(,(string-symbol 
(string-append @ ns))
+(if (lexical-token? tok) 
(lexical-token-source tok) tok))
+  (loop (+ i 1) rest)
 '()))
   '()))
,(if (= nt 0)
@@ -1879,17 +1882,11 @@
 (lexical-token-category tok)
 tok))
 
-  (define (___value tok)
-(if (lexical-token? tok)
-(lexical-token-value tok)
-tok))
-  
   (define (___run)
 (let loop ()
   (if ___input
   (let* ((state (vector-ref ___stack ___sp))
  (i (___category ___input))
- (attr  (___value ___input))
  (act   (___action i (vector-ref ___atable state
 
 (cond ((not (symbol? i))
@@ -1918,7 +1915,7 @@
  
   ;; Shift current token on top of the stack
   ((= act 0)
-   (___shift act attr)
+   (___shift act ___input)
(set! ___input (if (eq? i '*eoi*) '*eoi* #f))
(loop))
  
@@ -2025,8 +2022,7 @@
   (define (run)
 (let loop-tokens ()
   (consume)
-  (let ((symbol (token-category *input*))
-(attr   (token-attribute *input*)))
+  (let ((symbol (token-category *input*)))
 (for-all-processes
  (lambda (process)
(let loop ((stacks (list process)) (active-stacks '()))
@@ -2044,7 +2040,7 @@
  (add-parse (car (take-right stack 2)))
  (actions-loop other-actions 
active-stacks))
 ((= action 0)
- (let ((new-stack (shift action attr 
stack)))
+ (let ((new-stack (shift action *input* 
stack)))
(add-process new-stack))
  (actions-loop other-actions 
active-stacks))
 (else
-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http

cannot compile: srfi-10 define-reader-ctor 'hash '#,(

2014-07-04 Thread Jan Nieuwenhuizen
Hi,

The attached hash.scm works fine with guile-1.8.  With Ubuntu 14.04's
guile-2.0.9 and latest GIT master

5ded849 Convert slot allocation to use intsets

I do get output but compilation fails:

$ guile  ./hash.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;   or pass the --no-auto-compile argument to disable.
;;; compiling /home/janneke/vc/verum/development/language/asd/./hash.scm
;;; WARNING: compilation of 
/home/janneke/vc/verum/development/language/asd/./hash.scm failed:
;;; ERROR: unknown hash-comma tag  hash
cat

Is this a bug in the documentation, in guile, or ...?

I need to produce a json file from a guile tree that currently
looks like

   ((event0 (state (var .  value) ...) (trace (loc0 loc1 ...))) ... )

contents of the tree are symbols and numbers.  I hacked guile-json to
grok and produce symbols too.  So far so good for lists.  

However, json wants hash maps.  SRFI-10 hash looked like a nice ascii
data exchange format for hash maps.  (I would like to have pretty-print
use that notation too, as an alternative for the opaque

   #hash-table b87480 0/31

I get a suspicious feeling that I'm doing something very wrong if no one
else is using this, please enlighten me?

Greetings,
Jan



hash.scm
Description: Binary data

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  


,break-at-source ?

2014-07-04 Thread Jan Nieuwenhuizen
Hi,

I cannot get ,break-at-source to work.  Is this a bug?

$ guile
GNU Guile 2.1.0.1098-5ded
Copyright (C) 1995-2014 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user) ,m (break)
scheme@(break) ,break-at-source ./break.scm 15
While executing meta-command:
ERROR: No procedures found at ~a:~a. ./break.scm 15
scheme@(break) ,break-at-source ./break.scm 14
While executing meta-command:
ERROR: No procedures found at ~a:~a. ./break.scm 14
scheme@(break) ,break main
Trap 2: Breakpoint at #procedure main args.
scheme@(break) 

break-at-source is very handy, possible even required, for integration
into IDEs like GUD or Eclipse.

Greetings,
Jan



break.scm
Description: Binary data

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  


take! 0==1?

2013-07-12 Thread Jan Nieuwenhuizen
Hi,

Reading the documentation of take!

-- Scheme Procedure: take lst i
-- Scheme Procedure: take! lst i
Return a list containing the first I elements of LST.

`take!' may modify the structure of the argument list LST in order
to produce the result.

its behaviour surpsises me.

For list LST, (take! lst 0) leaves LST in the same state
as (take! lst 1) does.  Worse, the return value suggests
that it worked

scheme@(guile-user) (use-modules (srfi srfi-1))
scheme@(guile-user) (define lst '(a))
scheme@(guile-user) (take! lst 0)
$4 = ()
scheme@(guile-user) lst
$5 = (a)
scheme@(guile-user) (take! lst 1)
$6 = (a)
scheme@(guile-user) lst
$7 = (a)
scheme@(guile-user)

How are you doing such things?  Is anyone using take! at all to reduce a
list to n elements?  Using list-cdr-set! and set!/list-set! also seems a bit
clumsy.

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



Resolved: ! often means may, not will [WAS: Re: take! 0==1?]

2013-07-12 Thread Jan Nieuwenhuizen
William ML Leslie writes:

 Actually, I should clarify a few things, but this discussion probably
 belongs on guile-user.

I realise that now, reading below...

 Whenever the documentation says 'may', it really means it.  You
 absolutely cannot rely on the side-effecting behaviour, because an
 implementation that does no mutation whatsoever is a valid
 implementation of (take!), according to the documentation.  All you're
 saying by using (take!) is, if it is more efficient to do so by
 altering the list, then please do.

Thank you for this clue-bat.

Wow, I never realised that !/_x is only a performance/ugliness thingy,
except when used with set!.  I somehow assumed `!' meant: will alter
in-place.  My bad.

Is there really a good reason for exposing such performance
considerations to the user; can't the compiler [often] tell whether it's
safe to modify in place?

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



Re: Guile with win32 cross compiling

2011-05-20 Thread Jan Nieuwenhuizen
Volker Grabsch writes:

 1) My first attempt is to enable threads via:

Just to remind you that we have an automated working mingw cross build
setup here

https://github.com/janneke/gub

with guile-specific recipe and patches up at

https://github.com/janneke/gub/blob/guile-2.0/gub/specs/guile.py
https://github.com/janneke/gub/tree/guile-2.0/patches

Jan

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl



Re: [PATCH 2/5] [mingw]: Have compiled-file-name produce valid names.

2011-05-20 Thread Jan Nieuwenhuizen
Andy Wingo writes:

 I don't much like this approach.  Besides mixing in a heuristic on all
 machines that is win32-specific, it makes c:/foo.scm collide with
 d:/foo.scm in the cache, and fails to also modify load.c which also does
 autocompilation in other contexts.

Yes, a newer version of this patch also includes load.c and boot-9.scm.
Of course the drive letter should be kept.

 Is anyone interested in implementing a path library?

What's the status/estimate on this -- of course I agree this would be
nicer, otoh, a patch to these three files is available that makes guile
run on mingw right now.

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl



Re: [PATCH 1/5] [mingw]: Add implementation of canonicalize_file_name.

2011-05-20 Thread Jan Nieuwenhuizen
Andy Wingo writes:

 I read the thread and it looked like this patch was close to being
 accepted

Yes, it looks like that.

My first simplistic patch to just make guile canonicalize_file_name work
on mingw took my an hour to write and test.

I spent four full working days arguing with gnulib of the necessity of
the patch, writing tests, writing, talking, rewriting a new patch.

It's my estimate that it will only take two to four working days to get
this in gnulib.  I'm not planning to do that without sponsoring, sorry.

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl



Re: [PATCH 3/5] [mingw]: Do not export opendir, readdir etc., as dirents differ.

2011-05-20 Thread Jan Nieuwenhuizen
Andy Wingo writes:

 If mingw defines variants of these routines, why are we not using them
 directly?

Good question.  That may well be a better approach.

Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl



Re: [PATCH 5/5] [mingw]: Use $LOCALAPPDATA as a possible root for cachedir.

2011-05-20 Thread Jan Nieuwenhuizen
Andy Wingo writes:

  * libguile/load.c (scm_init_load_path) [MINGW32]: Use $LOCALAPPDATA
  to avoid having a NULL cachedir, while still allowing override by
  using $XDG_CACHE_HOME.

 What sets LOCALAPPDATA?  If it is the right thing on Windows then I am
 OK with applying this patch.

Asking google, it seems that this is a newer Windows versions thing.
Quite probably using plain $APPDATA is better.  Whether either one is
the right thing on windows -- if there's even such a thing -- I really
don't have a clue, you would need to ask a windows guru for that.

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl



Re: [PATCH 4/5] [mingw]: Delete existing target file before attempting rename.

2011-05-20 Thread Jan Nieuwenhuizen
Andy Wingo writes:

 This patch has the obvious race condition.

Yes.

 Why does the `rename' library routine not work on Win32?

Good question.

 The man page says

 CONFORMING TO
4.3BSD, C89, C99, POSIX.1-2001.

 so I am surprised about this behavior.

Yes, that's interesting.  Now what's broken here, the documentation, the
implementation, some specific implementation, the one windows box that
I tested on?

Greetings,
Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl



Re: [PATCH 4/5] Inline the effect of am/pre-inst-guile

2011-03-22 Thread Jan Nieuwenhuizen
Neil Jerram schreef op ma 21-03-2011 om 22:19 [+]:

 It's just one variable definition, and in my opinion it confuses,
 rather than helps, the overall build picture to have two names
 (preinstguile and meta/guile) for the same thing.

Ah, but in my cross build recipe, i have something like

   preinstguile=$GUILE_FOR_BUILD

I know this isn't nice, I think preinstguile should go
and we should use $GUILE_FOR_BUILD throughout.

It's just one variable, but one that you can override,

 - $(preinstguile) -l $(srcdir)/$(snarf_doc).scm -c   
 \
 + $(top_builddir_absolute)/meta/guile -l $(srcdir)/$(snarf_doc).scm   
 \
 +  -c
 \

How do you suggest this works during cross compiling?

Greetings,
Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




Re: problems solved by AC_LIB_HAVE_LINKFLAGS [was: cross building 1.9.14 for mingw]

2011-03-20 Thread Jan Nieuwenhuizen
Ralf Wildenhues schreef op zo 20-03-2011 om 09:21 [+0100]:

 Bruno already explained why it is not a good idea to let DESTDIR
 be the indicator of whether to look in /usr or not.

Ouch, I think I missed that.  Does someone have a pointer?
Also, why look in /usr before looking in gcc's library search path?
If we'd look in /usr last, $DESTDIR builds would most probably
not even need this --with-sysroot option and all would be happy?

Greetings,
Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




Re: Cross-compiling Guile 2.0

2011-03-16 Thread Jan Nieuwenhuizen
Neil Jerram schreef op za 05-03-2011 om 19:47 [+]:
 In principle, how should Guile 2.0 be cross-compiled? 

We're using GUB -- http://lilypond.org/gub and are
sucessfully cross-building guile-2.0.  You may want
to look at some patches

https://github.com/janneke/gub/tree/guile-2.0/patches

and te recipe

https://github.com/janneke/gub/blob/guile-2.0/gub/specs/guile.py

 (The target is my Openmoko Freerunner phone.)

Ah, GUB used to have arm architectures, not sure
how up to date they are.

Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




stable-2.0: In procedure module-lookup: Unbound variable: for-each

2011-03-16 Thread Jan Nieuwenhuizen
Good news: with guile stable-2.0 (958173e4), the module-lookup for-each
problem running from compiled cache

http://lists.gnu.org/archive/html/guile-devel/2011-02/msg00213.html

Yay!

Bad news: schikkers-list still does not run, showing a similar problem.
The problem is the same for a fresh and a compiled run (I guess this
also is good news).

With attached run.scm and use.scm in cwd, doing


$ ~/schikkers-list/usr/bin/guile -L . ./run.scm

results in

14:18:05 janneke@vuurvlieg:~/vc/schikkers-list
$ ~/schikkers-list/usr/bin/guile -L . ./run.scm 
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;   or pass the --no-auto-compile argument to disable.
;;; compiling /home/janneke/vc/schikkers-list/./run.scm
;;; compiling /home/janneke/vc/schikkers-list/use.scm
;;; /home/janneke/vc/schikkers-list/use.scm:12:2: warning: possibly unbound 
variable `for-each'
;;; compiled 
/home/janneke/.cache/guile/ccache/2.0-LE-4-2.0/home/janneke/vc/schikkers-list/use.scm.go
;;; compiled 
/home/janneke/.cache/guile/ccache/2.0-LE-4-2.0/home/janneke/vc/schikkers-list/run.scm.go
Backtrace:
In ice-9/boot-9.scm:
 170: 12 [catch #t #catch-closure 90d5280 ...]
In unknown file:
   ?: 11 [catch-closure]
In ice-9/boot-9.scm:
  62: 10 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 389: 9 [eval # #]
In ice-9/boot-9.scm:
1917: 8 [save-module-excursion #procedure 8fe42e0 at 
ice-9/boot-9.scm:3339:3 ()]
3346: 7 [#procedure 8fe42e0 at ice-9/boot-9.scm:3339:3 ()]
In unknown file:
   ?: 6 [load-compiled/vm 
/home/janneke/.cache/guile/ccache/2.0-LE-4-2.0/home/janneke/vc/schikkers-list/run.scm.go]
In /home/janneke/vc/schikkers-list/./run.scm:
  11: 5 [#procedure 9519000 ()]
In oop/goops.scm:
1556: 4 [#procedure 945d1e0 at oop/goops.scm:1554:0 (class . initargs) #]
In unknown file:
   ?: 3 [%initialize-object #notation 951cc60 ()]
In oop/goops.scm:
1556: 2 [#procedure 945d1e0 at oop/goops.scm:1554:0 (class . initargs) #]
In unknown file:
   ?: 1 [%initialize-object #music-document 951cbc0 ()]
In /home/janneke/vc/schikkers-list/use.scm:
  11: 0 [test-expr]

/home/janneke/vc/schikkers-list/use.scm:10:0: In procedure test-expr:
/home/janneke/vc/schikkers-list/use.scm:10:0: In procedure module-lookup: 
Unbound variable: for-each
[1]14:18:10 janneke@vuurvlieg:~/vc/schikkers-list
$ 

Greetings,
Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  
(define-module (run)
  #:use-module (oop goops)
  ;;
  #:use-module (use)
  #:export (main))

(define-class notation ()
   (music #:init-form (make music-document)))

(define-class run-app ()
  (notation #:init-value (make notation)))

(define (main)
  (format #t hello\n))

(main)
(define-module (use)
  #:use-module (oop goops)
  #:use-module (srfi srfi-1)
  ;;
  #:duplicates (merge-generics)
  #:export (music-document
))

(define-class music ())

(define (test-expr)
  (for-each display '()))

(define-class music-document ()
  (music #:init-form (test-expr) #:init-keyword #:music))



build error: race problem in mkdir?

2011-03-16 Thread Jan Nieuwenhuizen
I got the error below building today's stable-2.0.

It seems that ensure-writable-dir in compile.scm can
be raced.

Greetings,
Jan.

guile-tools compile -Wunbound-variable -Warity-mismatch -Wformat -o 
oop/goops/composite-slot.go 
/home/janneke/vc/gub/target/tools/src/guile-2.0.0.1/module/oop/goops/composite-slot.scm
Backtrace:
In ice-9/boot-9.scm:
 170: 9 [catch #t #catch-closure 977da80 ...]
In unknown file:
   ?: 8 [catch-closure]
In ice-9/boot-9.scm:
  62: 7 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 389: 6 [eval # #]
 350: 5 [eval # #]
In unknown file:
   ?: 4 [for-each #procedure 9948c30 at ice-9/eval.scm:378:13 (a) #]
In ice-9/eval.scm:
 350: 3 [eval # #]
 434: 2 [lp (#fluid 20) ()]
In system/base/compile.scm:
 128: 1 [compile-file 
/home/janneke/vc/gub/target/tools/src/guile-2.0.0.1/module/oop/goops.scm ...]
In unknown file:
   ?: 0 [mkdir oop #undefined]

ERROR: In procedure mkdir:
ERROR: In procedure mkdir: File exists
make[2]: *** [oop/goops.go] Error 1
make[2]: *** Waiting for unfinished jobs

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




Re: on second/.go-cached run: ERROR: Unbound variable: for-each - simplified

2011-02-25 Thread Jan Nieuwenhuizen
Ludovic Courtès schreef op do 24-02-2011 om 22:52 [+0100]:

Hi Ludovic,

 Would you like to debug further, e.g., by adding ‘pk’s in boot-9.scm in
 ‘merge-generics’?  :-)

Aren't you seeing this problem?  I only see

(module-define! m 'merge-generics noop)

in boot-9.scm ...

Greetings, Jan
-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




Re: cross building 1.9.14 for mingw

2011-02-24 Thread Jan Nieuwenhuizen
Andy Wingo schreef op di 22-02-2011 om 09:34 [+0100]:

Hi Andy,

 Excuse the long quote here

No problem.

  I did, and Bruno Haible does not really care about this brokenness
  or about cross compiling;
 
 That is a totally unfair characterization, Jan.  You met him in the
 Hague and he did not seem particularly evil then :)

Why, of course not.  Good point!

As anyone with some basic understanding of the human psyche can  
testify: any characterization that you make of someone or something 
says next to nothing about the subject, but -- if you catch yourself
doing it -- may tell you a whole lot about yourself.  Thanks for
catching me, I apologise for my behaviour and will have a good look
into the evil in me.

 Have you noticed that Guile has similar flags?

Yes, lots of packages have these; it's just that I always thought these
flags were for broken compilers or esoteric setups.  There are over 250
packages in GUB's cross build system, and until now, it has not been
necessary to specify --with-libFOO=$DESTDIR/usr/lib for any of those.

 To be honest I don't find it too onerous to have to set these flags when
 compiling with DESTDIR.  Sure, it would be nicer if it were just one
 flag, and perhaps we can fix that; but as you have perhaps seen in the
 numerous discussions on bug-guile recently, it seems that
 AC_LIB_HAVE_LINKFLAGS solves real problems.

I'm glad to hear that, at least it means that my cross build troubles
were for a good cause...  So now I need to look into the problems
that AC_LIB_HAVE_LINKFLAGS actually solves and see how to keep solving
them while not breaking zero-config DESTDIR-builds.

 People who cross-compile are a hardy breed, and less numerous than
 normal folk.  If the outcome here is that you have to pass more
 configure flags, but I have to deal with less mail on bug-guile, thus
 actually letting me hack again (!), I will take AC_LIB_HAVE_LINKFLAGS
 any day ;)

Haha!  Let me see if I understand you correctly: You are happy to get
less bug reports, which means more time to hack, even if it means that
cross build systems (such as mine) get more fragile and cross builders
will have to spend some of the time that you win, to maintain them?

Actually, this fits my idea that upstream time is most precious.  The
irony here, is that Han-Wen and I created GUB to give us more time
to hack: distribute turn-key binaries for everyone, so that we don't
have to deal with bug-reports of users trying to build from source.

To be serious, I had the dubious thought that what AC_LIB_HAVE_LINKFLAGS
was fixing by looking in /usr, must essentially be broken setups.
If that's the case, I would much rather see we find a way to fix
or prevent such broken setups, rather than trying to be smarter than
gcc and break well-behaved -- even if rarely used -- DESTDIR setups.

I realise that DESTDIR setups were not broken per se, but it was
considered a good trade-off to induce a maintenance burden to cross
builders because it would help users and upstream.

 I appreciate the work that you are doing on MinGW.  It will be nice for
 the oppressed denizens of Microsoft to have Guile relief.  So, ánimo,
 peregrino: we'll get there yet.

Thanks and yes, that's a helpful attitude.  Almost there...

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




on second/.go-cached run: ERROR: Unbound variable: for-each - simplified

2011-02-23 Thread Jan Nieuwenhuizen
Jan Nieuwenhuizen schreef op do 03-02-2011 om 21:20 [+0100]:

This morning I've spend some time to reduce this problem into
a single scheme file, see attached.  

Again, here's what happens when I run it twice, starting from
a clean cache.  

First run

12:47:07 janneke@vuurvlieg:~/vc/schikkers-list
$ rm -rf ~/.cache/guile
12:47:10 janneke@vuurvlieg:~/vc/schikkers-list
$ ./compile-cache-run-problem.scm 
;;; note: autocompilation is enabled, set GUILE_AUTO_COMPILE=0
;;;   or pass the --no-autocompile argument to disable.
;;; compiling ./compile-cache-run-problem.scm
;;; compiled 
/home/janneke/.cache/guile/ccache/2.0-0.T-LE-4/home/janneke/vc/schikkers-list/compile-cache-run-problem.scm.go
HALLO
12:47:16 janneke@vuurvlieg:~/vc/schikkers-list

Second run

$ ./compile-cache-run-problem.scm 
Backtrace:
In module/ice-9/boot-9.scm:
 170: 13 [catch #t #catch-closure 86895a0 ...]
In unknown file:
   ?: 12 [catch-closure]
In module/ice-9/boot-9.scm:
  62: 11 [call-with-prompt prompt0 ...]
In module/ice-9/eval.scm:
 389: 10 [eval # #]
In module/ice-9/boot-9.scm:
1864: 9 [save-module-excursion #procedure 8697c78 at 
module/ice-9/boot-9.scm:1878:3 ()]
1172: 8 [load ./compile-cache-run-problem.scm #f]
In unknown file:
   ?: 7 [load-compiled/vm 
/home/janneke/.cache/guile/ccache/2.0-0.T-LE-4/home/janneke/vc/schikkers-list/compile-cache-run-problem.scm.go]
In ./compile-cache-run-problem.scm:
  20: 6 [#procedure 868a560 ()]
In module/oop/goops.scm:
1552: 5 [#procedure 8afe820 at module/oop/goops.scm:1550:0 (class . 
initargs) #]
In unknown file:
   ?: 4 [%initialize-object #notation 8b01010 ()]
In module/oop/goops.scm:
1552: 3 [#procedure 8afe820 at module/oop/goops.scm:1550:0 (class . 
initargs) #]
In ./compile-cache-run-problem.scm:
  12: 2 [#procedure 8b04e40 at ./compile-cache-run-problem.scm:10:0 (obj . 
initargs) # ...]
In module/ice-9/boot-9.scm:
 115: 1 [#procedure 85fc4d8 at module/ice-9/boot-9.scm:110:6 (thrown-k . 
args) unbound-variable ...]
In unknown file:
   ?: 0 [catch-closure unbound-variable module-lookup ...]

ERROR: In procedure module-lookup:
ERROR: Unbound variable: for-each
[1]12:47:17 janneke@vuurvlieg:~/vc/schikkers-list
$ 

Greetings,
Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  
#! /bin/sh
# -*- scheme -*-
exec guile --debug -s $0 $@
!#

(define-module (ikli ikli)
  #:use-module (oop goops)
  #:use-module (srfi srfi-1)
  #:duplicates (merge-generics))

(define-class music-document ())

(define-method (initialize (obj music-document) . initargs)
  (let* ((self (next-method)))
(for-each (lambda (x) #f) '())
(map (lambda (x) #f) '())
self))

(define-class notation ()
   (music #:init-form (make music-document)))

(define-class ikli-app ()
   (notation #:init-value (make notation)))

(define (main)
  (format #t HALLO\n))

(main)


Re: cross building 1.9.14 for mingw

2011-02-15 Thread Jan Nieuwenhuizen
Ludovic Courtès schreef op za 29-01-2011 om 22:34 [+0100]:

  From 4aeb4bb48423d87001b598030afed0a2dc03e747 Mon Sep 17 00:00:00 2001
  From: Jan Nieuwenhuizen jann...@gnu.org
  Date: Sat, 29 Jan 2011 19:42:46 +0100
  Subject: [PATCH 2/4] Use AC_CHECK_LIB rather than AC_LIB_HAVE_LINKFLAGS.  
  Fixes cross configuring.
 
  AC_LIB_HAVE_LINKFLAGS blondly looks in $prefix etc. for libraries.
  Not only is that unnecessary, it also breaks cross building.
 
  Here's what config.log says:
 
  configure:33053: i686-mingw32-gcc -mms-bitfields -std=gnu99 -o 
  conftest.exe -O2 -DHAVE_CONFIG_H=1 
  -I/home/janneke/vc/gub/target/mingw/build/guile-1.9.14 
  -I/home/janneke/vc/gub/target/mingw/root/usr/include 
  -L/home/janneke/vc/gub/target/mingw/root/usr/lib 
  -L/home/janneke/vc/gub/target/mingw/root/usr/bin 
  -L/home/janneke/vc/gub/target/mingw/root/usr/lib/w32api conftest.c 
  /usr/lib/libltdl.a /usr/lib/libdl.a  5
  /tmp/cc5v8vq5.o:conftest.c:(.text+0x1e): undefined reference to 
  `_lt_dlopenext'
 
  note that using -lltdl -ldl instead of /usr/lib/libltdl.a
  /usr/lib/libdl.la works fine.
 
 Ouch.  May I suggest reporting it to bug-gnu...@gnu.org?  :-)  I think
 people there would be happy to provide an appropriate fix and we
 wouldn’t even have to worry.  ;-)

I did, and Bruno Haible does not really care about this brokenness
or about cross compiling; he throws the towel on fixing this and
defends it by arguing that there are more users with a broken
compiler/linker, installed in /usr, which must be helped to find libs
in /usr/lib, than there are cross build users who have a sane setup and 
suffer by this.

In fact he thinks it's a feature that configure breaks when you
upgrade from autoconf's AC_CHECK_LIB to gnulib's
AC_LIB_HAVE_LINKFLAGS.

So I would suggest to take my patch and not use AC_LIB_HAVE_LINKFLAGS,
and possibly work with Ralf Wildenhues from autotools to provide
any extra autoconf functionality in autoconf itself, rather than
working through gnulib.  Ralf does have a good understandng about
cross building.

Bruno suggests that cross build environments (or more accurately,
build environments that install in another or clean DESTDIR
than where the buildtools are), should now start using or introduce
special configure flags, so that what worked previously, now can
be fixed by a tedious manual process, he writes

   For example, gettext's configure --help contains:

  --without-libpth-prefix don't search for PACKLIBS in includedir and libdir
  --without-libiconv-prefix don't search for PACKLIBS in includedir and 
libdir
  --without-libintl-prefix don't search for PACKLIBS in includedir and 
libdir
  --without-libglib-2.0-prefix don't search for PACKLIBS in includedir and 
libdir
  --without-libcroco-0.6-prefix don't search for PACKLIBS in includedir and 
libdir
  --without-libunistring-prefix don't search for PACKLIBS in includedir and 
libdir
  --without-libxml2-prefix don't search for PACKLIBS in includedir and 
libdir
  --without-libncurses-prefix don't search for PACKLIBS in includedir and 
libdir
  --without-libtermcap-prefix don't search for PACKLIBS in includedir and 
libdir
  --without-libxcurses-prefix don't search for PACKLIBS in includedir and 
libdir
  --without-libcurses-prefix don't search for PACKLIBS in includedir and 
libdir
  --without-libexpat-prefix don't search for PACKLIBS in includedir and 
libdir

Greetings,

Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




Re: New problem with Windows port

2011-02-15 Thread Jan Nieuwenhuizen
carlo.bra...@libero.it schreef op di 15-02-2011 om 11:11 [+0100]:

Hi Carlo,

 while I was applying with my hacks on the latest candidate release of GUILE, 
 I 
 got this error in many sources, apparently without solution:
 
 .libs/socket.o: In function `scm_socket':
 C:/msys/home/Carlo/guile/libguile/../../guile-1.9.15/libguile/socket.c:439: 
 undefined reference to `socket_used_without_requesting_gnulib_module_socket'

See my cross building 1.9.14 for mingw patches, you'll have to run
gnulib-tools again to include socket and probably more modules.

Greetings,
Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




[PATCH 1/5] [mingw]: Add implementation of canonicalize_file_name.

2011-02-15 Thread Jan Nieuwenhuizen
From: Jan Nieuwenhuizen jann...@gnu.org

It does not look like this will be fixed any time soon in gnulib.

2011-02-04  Jan Nieuwenhuizen  jann...@gnu.org

* libguile/filesys.h:
* libguile/filesys.c (mingw_canonicalize_file_name)[__MINGW32__]: Add
minimal implementation of canonicalize_file_name for Mingw.
---
 libguile/filesys.c |   68 
 libguile/filesys.h |6 
 2 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/libguile/filesys.c b/libguile/filesys.c
index 68d90d9..93b0ce2 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -1631,6 +1631,74 @@ SCM_DEFINE (scm_basename, basename, 1, 1, 0,
 }
 #undef FUNC_NAME
 
+#ifdef __MINGW32__
+/* gnulib's canonicalize_file_name silently fails on Mingw.  */
+#include ctype.h
+#include direct.h
+#include windows.h
+
+static char const *
+slashify (char const *str)
+{
+  char *p = (char*)str;
+  
+  while (*p)
+{
+  if (*p == '\\')
+   *p = '/';
+  p++;
+}
+  return str;
+}
+
+static char const *
+strlower (char const *str)
+{
+  char *p = str;
+  while (*p)
+{
+  *p = (char)tolower (*p);
+  p++;
+}
+  return str;
+}
+
+static char *
+mingw_realpath (char const *name, char *resolved)
+{
+  char *rpath = NULL;
+
+  if (name == NULL || name[0] == '\0')
+return NULL;
+
+  if (resolved == NULL)
+{
+  rpath = malloc (PATH_MAX + 1);
+  if (rpath == NULL)
+  return NULL;
+}
+  else
+rpath = resolved;
+
+  GetFullPathName (name, PATH_MAX, rpath, NULL);
+  strlower (slashify (rpath));
+  struct stat st;
+  if (lstat (rpath, st)  0)
+{
+  if (resolved == NULL)
+   free (rpath);
+  return NULL;
+}
+  return rpath;
+}
+
+char *
+mingw_canonicalize_file_name (char const *name)
+{
+  return mingw_realpath (name, NULL);
+}
+#endif /* __MINGW32__ */
+
 SCM_DEFINE (scm_canonicalize_path, canonicalize-path, 1, 0, 0, 
 (SCM path),
Return the canonical path of @var{path}. A canonical path has\n
diff --git a/libguile/filesys.h b/libguile/filesys.h
index 967ce74..2f11e85 100644
--- a/libguile/filesys.h
+++ b/libguile/filesys.h
@@ -27,6 +27,12 @@
 
 
 
+#ifdef __MINGW32__
+extern char *mingw_canonicalize_file_name  (char const *name);
+#undef canonicalize_file_name
+#define canonicalize_file_name mingw_canonicalize_file_name
+#endif /* __MINGW32__ */
+
 SCM_API scm_t_bits scm_tc16_dir;
 
 #define SCM_DIR_FLAG_OPEN (1L  0)
-- 
1.7.1

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



[PATCH 4/5] [mingw]: Delete existing target file before attempting rename.

2011-02-15 Thread Jan Nieuwenhuizen
From: Jan Nieuwenhuizen jann...@gnu.org

2011-02-15  Jan Nieuwenhuizen  jann...@gnu.org

* libguile/filesys.c [MINGW32] (my_rename): Add implementation
that deletes target if it exists.  Fixes rename behaviour.
---
 libguile/filesys.c |   24 +---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/libguile/filesys.c b/libguile/filesys.c
index 880ee86..a2be2d5 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -680,9 +680,10 @@ SCM_DEFINE (scm_link, link, 2, 0, 0,
 #undef FUNC_NAME
 #endif /* HAVE_LINK */
 
-#ifdef HAVE_RENAME
+#if defined (HAVE_RENAME)  !defined (__MINGW32__)
 #define my_rename rename
-#else
+#else /* !HAVE_RENAME || __MINGW32__ */
+#ifndef __MINGW32__
 static int
 my_rename (const char *oldname, const char *newname)
 {
@@ -698,7 +699,24 @@ my_rename (const char *oldname, const char *newname)
 }
   return rv;
 }
-#endif
+#else /* __MINGW32__ */
+static int
+my_rename (const char *oldname, const char *newname)
+{
+  int rv;
+  struct stat stat;
+
+  SCM_SYSCALL (rv = !stat (newname, stat));
+  if (rv != 0)
+SCM_SYSCALL (rv = unlink (newname));
+  if (rv == 0)
+rv = rename (oldname, newname);
+
+  return rv;
+}
+#endif /* __MINGW32__ */
+#endif /* !HAVE_RENAME || __MINGW32__ */
+
 
 SCM_DEFINE (scm_rename, rename-file, 2, 0, 0,
 (SCM oldname, SCM newname),
-- 
1.7.1

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



[PATCH 2/5] [mingw]: Have compiled-file-name produce valid names.

2011-02-15 Thread Jan Nieuwenhuizen
From: Jan Nieuwenhuizen jann...@gnu.org

2011-02-04  Jan Nieuwenhuizen  jann...@gnu.org

* module/system/base/compile.scm (compiled-file-name): Add
directory separator and remove colon for Mingw.  Fixes
compilation on Windows.
---
 module/system/base/compile.scm |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/module/system/base/compile.scm b/module/system/base/compile.scm
index 7d46713..8c72e54 100644
--- a/module/system/base/compile.scm
+++ b/module/system/base/compile.scm
@@ -100,11 +100,16 @@
.go)
   (else (car %load-compiled-extensions
   (and %compile-fallback-path
-   (let ((f (string-append
+   (let* ((c (canonicalize-path file))
+ (f (string-append
  %compile-fallback-path
  ;; no need for '/' separator here, canonicalize-path
  ;; will give us an absolute path
- (canonicalize-path file)
+(if (eq? (string-ref c 1) #\:)
+;; on Mingw remove drive-letter separator `:' to
+;; obtain valid file name
+(substring c 2)
+c)
  (compiled-extension
  (and (false-if-exception (ensure-writable-dir (dirname f)))
   f
-- 
1.7.1

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



[PATCH 3/5] [mingw]: Do not export opendir, readdir etc., as dirents differ.

2011-02-15 Thread Jan Nieuwenhuizen
From: Jan Nieuwenhuizen jann...@gnu.org

Without this patch, libguile exports symbols such as opendir, readdir,
which expect and use guile's struct dirent that differs from mingw's
dirent.  Linking to libguile when using mingw's dirent gives unexpected
results.

2011-02-15  Jan Nieuwenhuizen  jann...@gnu.org

* libguile/win32-dirent.c:
* libguile/filesys.c [MINGW32]: Include win32-dirent.h early,
to pick-up defines.

* libguile/win32-dirent.h (opendir, readdir, closedir, rewinddir,
seekdir, telldir, dirfd): #define to guile_opendir ect.
---
 libguile/filesys.c  |5 -
 libguile/win32-dirent.c |4 ++--
 libguile/win32-dirent.h |8 
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/libguile/filesys.c b/libguile/filesys.c
index 93b0ce2..880ee86 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -35,6 +35,10 @@
 #include stdio.h
 #include errno.h
 
+#if defined (__MINGW32__) || defined (_MSC_VER) || defined (__BORLANDC__)
+# include win32-dirent.h
+#endif /* __MINGW32__ || _MSC_VER || __BORLANDC__ */
+
 #include libguile/_scm.h
 #include libguile/smob.h
 #include libguile/feature.h
@@ -94,7 +98,6 @@
 
 
 #if defined (__MINGW32__) || defined (_MSC_VER) || defined (__BORLANDC__)
-# include win32-dirent.h
 # define NAMLEN(dirent) strlen((dirent)-d_name)
 /* The following bits are per AC_HEADER_DIRENT doco in the autoconf manual */
 #elif HAVE_DIRENT_H
diff --git a/libguile/win32-dirent.c b/libguile/win32-dirent.c
index de170c7..b5b2c60 100644
--- a/libguile/win32-dirent.c
+++ b/libguile/win32-dirent.c
@@ -20,14 +20,14 @@
 # include config.h
 #endif
 
+#include win32-dirent.h
+
 #include libguile/__scm.h
 
 #include windows.h
 #include stdio.h
 #include string.h
 
-#include win32-dirent.h
-
 DIR *
 opendir (const char * name)
 {
diff --git a/libguile/win32-dirent.h b/libguile/win32-dirent.h
index 578db49..f9f8fe9 100644
--- a/libguile/win32-dirent.h
+++ b/libguile/win32-dirent.h
@@ -27,6 +27,14 @@
 
 #include sys/types.h
 
+#define opendir guile_opendir
+#define readdir guile_readdir
+#define closedir guile_closedir
+#define rewinddir guile_rewinddir
+#define seekdir guile_seekdir
+#define telldir guile_telldir
+#define dirfd guile_dirfd
+
 struct dirstream
 {
   int fd;  /* File descriptor.  */
-- 
1.7.1

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



[PATCH 5/5] [mingw]: Use $LOCALAPPDATA as a possible root for cachedir.

2011-02-15 Thread Jan Nieuwenhuizen
From: Jan Nieuwenhuizen jann...@gnu.org

2011-02-15  Jan Nieuwenhuizen  jann...@gnu.org

* libguile/load.c (scm_init_load_path) [MINGW32]: Use $LOCALAPPDATA
to avoid having a NULL cachedir, while still allowing override by
using $XDG_CACHE_HOME.
---
 libguile/load.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libguile/load.c b/libguile/load.c
index c2380b9..48a28fe 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -283,6 +283,10 @@ scm_init_load_path ()
 
 if ((e = getenv (XDG_CACHE_HOME)))
   snprintf (cachedir, sizeof(cachedir), %s/ FALLBACK_DIR, e);
+#ifdef __MINGW32__
+else if ((e = getenv (LOCALAPPDATA)))
+  snprintf (cachedir, sizeof (cachedir), %s/.cache/ FALLBACK_DIR, e);
+#endif /* __MINGW32__ */
 else if ((e = getenv (HOME)))
   snprintf (cachedir, sizeof(cachedir), %s/.cache/ FALLBACK_DIR, e);
 #ifdef HAVE_GETPWENT
-- 
1.7.1

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



mingw runtime patches

2011-02-15 Thread Jan Nieuwenhuizen
I have now sucessfully cross-built guile-1.9 for mingw and used
it to run a simple guile-gnome GUI [http:/lilypond.org/schikkers-list].

Earlier I have sent a couple of configure and build-time patches,
what follows here are patches that I'm using to fix runtime problems.

Most obvious lacking is still the relocation patch which we discussed.
That needs more work to be used outside of our cross build system (GUB).

Greetings,
Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




Re: implicitly using existing function as generic fails in 1.9

2011-02-11 Thread Jan Nieuwenhuizen
Andy Wingo schreef op vr 11-02-2011 om 18:48 [+0100]:
 On Wed 02 Feb 2011 15:02, Jan Nieuwenhuizen janneke-l...@xs4all.nl writes:
 
  WARNING: (use): `remove!' imported from both (remove) and (srfi srfi-1)
 
 As far as I can tell, it never worked to merge generics between a
 regular procedure and a generic.

 And indeed that does not appear to work with 1.8.

I'm attaching the individual files; this works with 1.8.7:

19:52:20 janneke@vuurvlieg:~/vc/schikkers-list/remove
$ ./run.scm 
WARNING: (use): `remove!' imported from both (srfi srfi-1) and (remove)
class: remove!
19:52:24 janneke@vuurvlieg:~/vc/schikkers-list/remove

 I don't understand what's going on here, really.  Do you?

No, and if you say it's not supported, I'll just have to
choose other names for those functions.

Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  
(define-module (use)
  #:use-module (oop goops)
  #:use-module (srfi srfi-1)
  #:use-module (remove)
  #:export (main))

(define obj (make cls))

(define (main)
  (remove! obj))
#! /bin/sh
# -*- scheme -*-
exec guile --debug -L $(dirname $0) -s $0 $@
!#

;;(use-modules
;; (use))

((@ (use) main))

(define-module (remove)
  #:use-module (oop goops)
  #:use-module (srfi srfi-1)
  #:duplicates (merge-generics)
  #:export (cls
	remove!))

(define-class cls ())

(define-method (remove! (self cls))
  (format #t class: remove!\n))


Subject: on second/.go-cached run: ERROR: Unbound variable: for-each

2011-02-03 Thread Jan Nieuwenhuizen
Hi,

My embryonal LilyPond GUI now works with Guile 1.9.15, but
it cannot run from cached .go files -- see below.

Can you help me with this; how do I go about debugging this?

If/once you have a working guile-gnome setup which includes gnomecanvas,
simply do

git clone git://github.com/janneke/schikkers-list.git
cd schikkers-list
rm -rf ~/.cache/guile/
./ikli.scm

This is also the best option, at least until we have the binary
relocation for 1.9 fully handled.

If you don't have guile-gnome you can download and install either of


http://lilypond.org/schikkers-list/download/schikkers-list-0.0.1-2.linux-x86.sh

The .sh installs in ~/schikkers-list, run it [for now] by doing

cd ~/schikkers-list/usr/bin  $(pwd)/guile --debug -e main -s 
$(pwd)/schikkers-list

On the first run, it cannot find (ikli relocate) and it aborts.  On the second
run, it works!  Quit the program, run again, you get the for-each unbound error
below.

There's only one warning that I get

WARNING: (gnome gtk): `re-export-modules' imported from both (gnome gw 
support modules) and (gnome gobject utils)

If you don't have LilyPond = 2.13.37 installed, or no LilyPond at
all, you won't see any music but you can still choose File/Open or
Help/About to see that the GUI sort of works.

Starting it for the second time, i.e., using the compiled .go cache from
the first run, I get

15:19:04 janneke@vuurvlieg:~/vc/schikkers-list
$ ./ikli.scm 
Backtrace:
In module/ice-9/boot-9.scm:
1172: 19 [load ./ikli.scm #f]
In unknown file:
   ?: 18 [load-compiled/vm 
/home/janneke/.cache/guile/ccache/2.0-0.T-LE-4/home/janneke/vc/schikkers-list/ikli.scm.go]
In ./ikli.scm:
  55: 17 [main (./ikli.scm)]
In module/ice-9/boot-9.scm:
2266: 16 [#procedure 9695c30 at module/ice-9/boot-9.scm:2254:4 (name 
#:optional autoload version #:key ensure) # ...]
2532: 15 [try-module-autoload (ikli ikli) #f]
1864: 14 [save-module-excursion #procedure 9709918 at 
module/ice-9/boot-9.scm:2533:17 ()]
2543: 13 [#procedure 9709918 at module/ice-9/boot-9.scm:2533:17 ()]
In unknown file:
   ?: 12 [primitive-load-path ikli/ikli #f]
In /home/janneke/vc/schikkers-list/ikli/ikli.scm:
 220: 11 [#procedure 9710a60 ()]
In module/oop/goops.scm:
1552: 10 [#procedure 9b9cdd0 at module/oop/goops.scm:1550:0 (class . 
initargs) #]
In /home/janneke/vc/schikkers-list/ikli/notation.scm:
 199: 9 [#procedure 9a840f0 at 
/home/janneke/vc/schikkers-list/ikli/notation.scm:198:0 (obj . initargs) # ...]
In unknown file:
   ?: 8 [%initialize-object #notation 9cb2140 ()]
In /home/janneke/vc/schikkers-list/ikli/notation.scm:
 183: 7 [#procedure 99b6490 ()]
In module/oop/goops.scm:
1552: 6 [#procedure 9b9cdd0 at module/oop/goops.scm:1550:0 (class . 
initargs) #]
In unknown file:
   ?: 5 [%initialize-object #music-document a0f9b70 ()]
In /home/janneke/vc/schikkers-list/ikli/music.scm:
 667: 4 [test-expr]
In module/oop/goops.scm:
1552: 3 [#procedure 9b9cdd0 at module/oop/goops.scm:1550:0 (class . 
initargs) #]
In /home/janneke/vc/schikkers-list/ikli/music.scm:
 332: 2 [#procedure 9a8d750 at 
/home/janneke/vc/schikkers-list/ikli/music.scm:329:0 (obj . initargs) # ...]
In module/ice-9/boot-9.scm:
 115: 1 [#procedure 96754d8 at module/ice-9/boot-9.scm:110:6 (thrown-k . 
args) unbound-variable ...]
In unknown file:
   ?: 0 [catch-closure unbound-variable module-lookup ...]

ERROR: In procedure module-lookup:
ERROR: Unbound variable: for-each
[1]15:22:07 janneke@vuurvlieg:~/vc/schikkers-list

Greetings, Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




goops method defined only in derived classes fails to become generic?

2011-02-02 Thread Jan Nieuwenhuizen
[sorry moderator, sent from non-subscribed address]

Hi,

This worked with guile 1.8.  Bug or feature?

Greetings,
Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



class.tar.gz
Description: application/compressed-tar


implicitly using existing function as generic fails in 1.9

2011-02-02 Thread Jan Nieuwenhuizen
Hi,

See attached code, run using

   ./run.scm

1.8 says:

14:58:59 janneke@vuurvlieg:~/vc/schikkers-list/remove
$ ./run.scm
WARNING: (use): `remove!' imported from both (srfi srfi-1) and (remove)
class: remove!

1.9.14 says:

14:58:36 janneke@vuurvlieg:~/vc/schikkers-list/remove
$ rm -rf ~/.cache/guile/
14:59:10 janneke@vuurvlieg:~/vc/schikkers-list/remove
$ ./run.scm
;;; note: autocompilation is enabled, set GUILE_AUTO_COMPILE=0
;;;   or pass the --no-autocompile argument to disable.
;;; compiling ./run.scm
;;; compiling /home/janneke/vc/schikkers-list/remove/use.scm
;;; compiling /home/janneke/vc/schikkers-list/remove/remove.scm
;;; compiled 
/home/janneke/.cache/guile/ccache/2.0-0.T-LE-4/home/janneke/vc/schikkers-list/remove/remove.scm.go
WARNING: (use): `remove!' imported from both (remove) and (srfi srfi-1)
;;; compiled 
/home/janneke/.cache/guile/ccache/2.0-0.T-LE-4/home/janneke/vc/schikkers-list/remove/use.scm.go
;;; compiled 
/home/janneke/.cache/guile/ccache/2.0-0.T-LE-4/home/janneke/vc/schikkers-list/remove/run.scm.go
WARNING: (use): `remove!' imported from both (remove) and (srfi srfi-1)
WARNING: (use): `remove!' imported from both (srfi srfi-1) and (remove)
WARNING: (use): `remove!' imported from both (remove) and (srfi srfi-1)
Backtrace:
In module/ice-9/boot-9.scm:
 170: 9 [catch #t #catch-closure 86525a0 ...]
In unknown file:
   ?: 8 [catch-closure]
In module/ice-9/boot-9.scm:
  62: 7 [call-with-prompt prompt0 ...]
In module/ice-9/eval.scm:
 389: 6 [eval # #]
In module/ice-9/boot-9.scm:
1864: 5 [save-module-excursion #procedure 8660b88 at 
module/ice-9/boot-9.scm:1878:3 ()]
1172: 4 [load ./run.scm #f]
In unknown file:
   ?: 3 [load-compiled/vm 
/home/janneke/.cache/guile/ccache/2.0-0.T-LE-4/home/janneke/vc/schikkers-list/remove/run.scm.go]
   ?: 2 [remove! #cls 8b36380]
In module/ice-9/boot-9.scm:
 115: 1 [#procedure 85c64d8 at module/ice-9/boot-9.scm:110:6 (thrown-k . 
args) wrong-number-of-args ...]
In unknown file:
   ?: 0 [catch-closure wrong-number-of-args #f ...]

ERROR: In procedure catch-closure:
ERROR: Wrong number of arguments to #procedure remove! (_ _)
[1]14:59:12 janneke@vuurvlieg:~/vc/schikkers-list/remove
$ 

I haven't found the fix or workaround other than renaming the method to
`xremove!'.

Greetings,
Jan.



remove.tar.gz
Description: application/compressed-tar


goops method defined only in derived classes fails to become generic?

2011-02-02 Thread Jan Nieuwenhuizen
Hi,

This worked with guile 1.8.  Bug or feature?

Greetings,
Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  


class.tar.gz
Description: application/compressed-tar


Re: cross building 1.9.14 for mingw

2011-01-31 Thread Jan Nieuwenhuizen
Ludovic Courtès schreef op za 29-01-2011 om 22:34 [+0100]:

Hi Ludovic,

 OK but all the modules listed after ‘accept’ above are needed too,
 right?

Yes, sure.

 Hmm could it be that there was a typo?  Here running ‘git-version-gen’
 outside of a Git tree works fine:
 
   $ guile/build-aux/git-version-gen .tarball-version s/foo/bar/
   UNKNOWN

Yes, does it also work when you change configure.ac and autoreconf?

 Ouch.  May I suggest reporting it to bug-gnu...@gnu.org?  :-)  I think
 people there would be happy to provide an appropriate fix and we
 wouldn’t even have to worry.  ;-)

Yes, hat would be nice.

  --- a/libguile/bdw-gc.h
  +++ b/libguile/bdw-gc.h
  @@ -30,7 +30,9 @@
  allocation.  */
   
   # define GC_THREADS 1
  +#ifndef __MINGW32__
   # define GC_REDIRECT_TO_LOCAL 1
  +#endif /* __MINGW32__ */
 
 Why?

I'm using gc-6.8 and cannot seem to build a version for Mingw that
includes GC_local_malloc -- that seems to be for linux pthreads only.

Removing this redirect to local, fixes these

.libs/libguile_2.0_la-alist.o:alist.c:(.text+0x6bf): undefined reference to 
`_GC_local_malloc'

build errors.

  -  buf-st_mode = _S_IFSOCK | _S_IREAD | _S_IWRITE | _S_IEXEC;
  +  buf-st_mode = _S_IREAD | _S_IWRITE | _S_IEXEC;
 
 Why?  Isn’t ‘_S_IFSOCK’ defined on all MinGW?

I don't have in it my mingw-runtime-3.14.  If there's a newer version,
I've misses something and would like to hear it.

  +#ifndef __MINGW32__
   /* Make sure the `AI_*' flags can be stored as INUMs.  */
   verify (SCM_I_INUM (SCM_I_MAKINUM (AI_ALL)) == AI_ALL);
 
 Does MinGW lack getaddrinfo?

No, it lacks the AI_* definitions.  I realise that you may not want
to include this just yet, although it documents my progress building
it for mingw.

 Gnulib’s ‘getaddrinfo’ module, which we use, is supposed to take care of
 this, i.e., it should fall back to ‘gethostbyname’ if needed.

Yes.

More bits in a new thread.

Thanks, greetings,
Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




Re: Relocatable installation

2011-01-31 Thread Jan Nieuwenhuizen
Ludovic Courtès schreef op za 29-01-2011 om 22:39 [+0100]:

Hi Ludovic,

 I’m not sure about this patch.  My feeling is that it would take more
 than this to allow Guile to be truly relocatable, e.g., all of
 $GUILE_LOAD_PATH, $GUILE_LOAD_COMPILED_PATH, $LD_LIBRARY_PATH,
 etc. would have to work.

I realised we need GUILE_LOAD_COMPILED_PATH too.  Added that
in this new patch.  I added a bit more explanation: this should
be used together with a sane -rpath $ORIGIN/../lib build.

 And some of them are hardcoded in the binary,
 as is usual with the GNU Build System.

Yes, that's why the new, argv0-based directories are prepended
to those paths.

 Furthermore, I think all these paths cannot be reliably inferred from
 argv[0].  For instance because libdir doesn’t have to be $bindir/../lib.
 It doesn’t seem to fit well in the GNU software installation process.

No, you can choose all kinds of freaky install directories.  However,
if you don't do that and use the normal, default directory structure,
this enables binary packages with guile that can be installed in
$HOME or on Windows in c:/Program Files/Whatever.

 Still I’d be glad to hear arguments for and against.  :-)

One argument for is that we've been using this in LilyPond binary
packages (for linux and windows) since 2005.

Greetings,
Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  
From d93b5bd21e99cda017e1b2d7b459e453113fbfa6 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen jann...@gnu.org
Date: Mon, 31 Jan 2011 21:05:48 +0100
Subject: [PATCH] Add dynamic relocation support, default off.

Set PATH, GUILE_LOAD_PATH, GUILE_LOAD_COMPILED_PATH according to
location of the guile executable.  Using this together with
-rpath $ORIGIN/../lib and not changing the general installed
directory layout, this enables relocatable binary packages,
for use in $HOME or for Windows.

2005-06-08  Jan Nieuwenhuizen  jann...@gnu.org

* configure.in: Add --enable-relocation option.  Default off.

libguile/ ChangeLog

2005-06-09  Jan Nieuwenhuizen  jann...@gnu.org

Experimental relocation patch.

* load.c (scm_init_argv0_relocation)[ARGV0_RELOCATION]: New
function.

(scm_init_load_path)[ARGV0_RELOCATION]: Use it.

* load.c (scm_c_argv0_relocation)[ARGV0_RELOCATION]:

* guile.c (main)[ARGV0_RELOCATION]: Use it to append from
executable location derived scm library directory.
[__MINGW32__|__CYGWIN__]: Append directory of executable to PATH.
---
 configure.ac |   12 +++
 libguile/guile.c |3 ++
 libguile/load.c  |   55 ++
 libguile/load.h  |5 
 4 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5c70aa8..5fa6cf4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1452,6 +1452,18 @@ GUILE_THREAD_LOCAL_STORAGE
 fi # with_threads=pthreads
 
 
+## Dynamic relocation, based on argv[0].
+reloc_p=no
+AC_ARG_ENABLE(relocation,
+[  --enable-relocation compile with dynamic relocation.  Default: off],
+[reloc_p=$enableval])
+
+if test $reloc_p = yes; then
+   AC_DEFINE([ARGV0_RELOCATION], [1], [Dynamic relocation])
+   AC_DEFINE_UNQUOTED([PATH_SEPARATOR], $PATH_SEPARATOR, [Path separator])
+   AC_DEFINE_UNQUOTED([GUILE_EFFECTIVE_VERSION], $GUILE_EFFECTIVE_VERSION, [GUILE_EFFECTIVE_VERSION])
+fi # $reloc_b
+
 ## Cross building	
 if test $cross_compiling = yes; then
   AC_MSG_CHECKING(cc for build)
diff --git a/libguile/guile.c b/libguile/guile.c
index 6da547b..896adc4 100644
--- a/libguile/guile.c
+++ b/libguile/guile.c
@@ -67,6 +67,9 @@ inner_main (void *closure SCM_UNUSED, int argc, char **argv)
 int
 main (int argc, char **argv)
 {
+#if ARGV0_RELOCATION
+  scm_c_argv0_relocation (argv[0]);
+#endif /* ARGV0_RELOCATION */
   scm_boot_guile (argc, argv, inner_main, 0);
   return 0; /* never reached */
 }
diff --git a/libguile/load.c b/libguile/load.c
index cbf9dc0..9ad1008 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -234,6 +234,53 @@ SCM_DEFINE (scm_parse_path, parse-path, 1, 1, 0,
 }
 #undef FUNC_NAME
 
+#if ARGV0_RELOCATION
+#include filesys.h
+#if defined (__CYGWIN__) || defined (__MINGW32__)
+#include posix.h
+#endif
+
+char const *global_argv0 = 0;
+
+void
+scm_c_argv0_relocation (char const *argv0)
+{
+  global_argv0 = argv0;
+}
+
+SCM
+scm_init_argv0_relocation (char const* argv0)
+{
+  SCM bindir = scm_dirname (scm_from_locale_string (argv0));
+  SCM prefix = scm_dirname (bindir);
+  SCM datadir = scm_string_append (scm_list_2 (prefix,
+	 scm_from_locale_string (/share/guile/ GUILE_EFFECTIVE_VERSION)));
+  SCM path;
+  char *env = getenv (PATH);
+  if (env)
+path = scm_string_append (scm_list_3 (bindir,
+	  scm_from_locale_string (env),
+	  scm_from_locale_string (PATH_SEPARATOR)));
+  else
+path = bindir;
+  scm_putenv (scm_string_append (scm_list_2 (scm_from_locale_string (PATH=), path

Re: Relocatable installation

2011-01-31 Thread Jan Nieuwenhuizen
Andy Wingo schreef op ma 31-01-2011 om 21:50 [+0100]:

Hi Andy,

 What about the extensions paths?  Are all paths from libpath.h
 relocatable?
 
 Curiously yours,

Good question, we [LilyPond installs] never needed/used those,
I guess.  I can imagine that more paths need to be added, this
was sufficient for guile-1.8, however.

Jan.

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  




  1   2   >