bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: slib with guile 1.9.7


From: Ludovic Courtès
Subject: Re: slib with guile 1.9.7
Date: Tue, 02 Feb 2010 23:17:27 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Hello,

[Adding Cc: bug-guile since it’s relevant.]

Aubrey Jaffer <address@hidden> writes:

>  | Date: Mon, 1 Feb 2010 17:37:50 +0100
>  | From: Petr Gajdos <address@hidden>
>  | 
>  | On Thu, Jan 28, 2010 at 08:59:33PM -0500, Aubrey Jaffer wrote:
>  | > [...]
>  | > 
>  | > Okay.  I conditionalized the 3 forms on guile-2.  I also repaired
>  | > "guile.init" for Guile-1.8.6, the version my Fedora-11 system runs.
>  | > 
>  | > The development version is updated:
>  | > http://groups.csail.mit.edu/mac/ftpdir/users/jaffer/slib.zip
>  | > Also, the CVS repository is updated:
>  | > https://savannah.gnu.org/cvs/?group=slib
>  | > 
>  | > Please try it out and see if it works for Guile-1.9.
>  | 
>  | Strictly following guile manual [1] I get with guile-1.9.7
>  | 
>  | laura:/usr/share/guile/1.9 # guile --no-autocompile -c "(use-modules 
> (ice-9 slib))"
>  | ERROR: In procedure sc-expand:
>  | ERROR: definition in expression context in subform `browse-url' of
>  | `(lambda (url)
>  |   (define (try cmd end)
>  |     (zero? (system (string-append cmd url end))))
>  |   (or (try "netscape-remote -remote 'openURL(" ")'")
>  |       (try "netscape -remote 'openURL(" ")'")
>  |       (try "netscape '" "'&")
>  |       (try "netscape '" "'")))
>  | '
>
> Does Guile's syncase not support internal function definitions?
>
> Does either of these definitions work?
>
> (if (not (defined? 'browse-url))
>     (define (browse-url url)
>       (define try
>       (lambda (cmd end) (zero? (system (string-append cmd url end)))))
>       (or (try "netscape-remote -remote 'openURL(" ")'")
>         (try "netscape -remote 'openURL(" ")'")
>         (try "netscape '" "'&")
>         (try "netscape '" "'"))))
>
> (if (not (defined? 'browse-url))
>     (define (browse-url url)
>       (letrec ((try
>               (lambda (cmd end)
>                 (zero? (system (string-append cmd url end))))))
>       (or (try "netscape-remote -remote 'openURL(" ")'")
>           (try "netscape -remote 'openURL(" ")'")
>           (try "netscape '" "'&")
>           (try "netscape '" "'")))))

No:

  scheme@(guile-user)> (if (not (defined? 'foo))(define foo 2))
  Throw to key `syntax-error':
  ERROR: In procedure sc-expand:
  ERROR: definition in expression context in subform `foo' of `2'

I wonder whether we should hack ‘if’ to support this idiom, for backward
compatibility, since it used to be relatively common.

At any rate, the following should work both with 1.8 and 2.0 (and
probably older versions):

  (if (not (defined? 'foo))
      (module-define! (current-module) 'foo 2))

Thanks,
Ludo’.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]