define-macro syntax error

2013-02-12 Thread Akop Pogosian
I am having problems getting simple define-macro to work in Guile 2.

For example, this:

(define-macro when
  (lambda (test . branch)
`(if ,test
 (begin ,@branch

will give an error:

While compiling expression:
ERROR: Syntax error:
unknown file:8:0: source expression failed to match any pattern in form (define\
-macro when (lambda (test . branch) (quasiquote (if (unquote test) (begin (unqu\
ote-splicing branch))


What's wrong here?



Re: define-macro syntax error

2013-02-12 Thread Daniel Hartwig
On 12 February 2013 16:15, Akop Pogosian  wrote:
> I am having problems getting simple define-macro to work in Guile 2.
>
> For example, this:
>
> (define-macro when
>   (lambda (test . branch)
> `(if ,test
>  (begin ,@branch

> What's wrong here?
>

This is not the right syntax.  From the manual:

> (define-macro (NAME ARGS ...) BODY ...)

so, in your case:

(define-macro (when test . branch)
  `(if ,test
   (begin ,@branch)))

Regards



Re: define-macro syntax error

2013-02-12 Thread Andy Wingo
On Tue 12 Feb 2013 09:15, Akop Pogosian  writes:

> (define-macro when
>   (lambda (test . branch)
> `(if ,test
>  (begin ,@branch
>
> will give an error:

This is a bug.  I just fixed it in stable-2.0; thanks for the report.

In the meantime, you can use:

  (define-macro (when test . branch)
...)

Sorry for the inconvenience.

Andy
-- 
http://wingolog.org/



Re: define-macro syntax error

2013-02-12 Thread Daniel Hartwig
On 12 February 2013 16:42, Andy Wingo  wrote:
> On Tue 12 Feb 2013 09:15, Akop Pogosian  writes:
>
>> (define-macro when
>>   (lambda (test . branch)
>> `(if ,test
>>  (begin ,@branch
>>
>> will give an error:
>
> This is a bug.  I just fixed it in stable-2.0; thanks for the report.

Curious.  Is that some syntax from an older version, or …?



Re: define-macro syntax error

2013-02-12 Thread Akop Pogosian
On Tue, Feb 12, 2013 at 3:26 AM, Daniel Hartwig  wrote:
> On 12 February 2013 16:42, Andy Wingo  wrote:
>> On Tue 12 Feb 2013 09:15, Akop Pogosian  writes:
>>
>>> (define-macro when
>>>   (lambda (test . branch)
>>> `(if ,test
>>>  (begin ,@branch
>>>
>>> will give an error:
>>
>> This is a bug.  I just fixed it in stable-2.0; thanks for the report.
>
> Curious.  Is that some syntax from an older version, or …?
>

I was testing examples from "Teach Yourself Scheme in Fixnum Days".
This is the format it uses.


-Akop



Re: define-macro syntax error

2013-02-12 Thread Ian Price
Akop Pogosian  writes:

> (define-macro when
>   (lambda (test . branch)
> `(if ,test
>  (begin ,@branch

FWIW, `when' is already available in Guile 2, and define-macro is
generally frowned upon. For these ultra-simple cases, prefer
define-syntax-rule.

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



Re: statically linking in srfi modules

2013-02-12 Thread Richard Shann
On Mon, 2013-02-11 at 12:03 -0500, Mark H Weaver wrote:
> Richard Shann  writes:
> > configure:31783: checking for main in -lregex
> > configure:31812: i686-pc-mingw32-gcc -o conftest.exe
> > -Wno-unused-but-set-variable
> > -I/home/rshann/mxe/usr/i686-pc-mingw32/include  conftest.c -lregex
> > -lgmp -lws2_32 -lm -lltdl -lunistring -lintl -liconv >&5
> > /home/rshann/mxe/usr/lib/gcc/i686-pc-mingw32/4.7.0/../../../../i686-pc-mingw32/bin/ld:
> >  cannot find -lregex
> >
> > probably in all cases.
> 
> Can you find out where the 'regcomp' function is? 
Well, I tracked back from the GNU/LilyPond build system - it seems to
originate in glibc, but in the GNU/LilyPond build system it has been
extracted out as a separate library. 
http://lilypond.org/download/gub-sources/regex-2.3.90-1.tar.bz2

By building this with --disable-shared I have obtained a library which
links to guile and ice-9/regex is now working inside Denemo.

Thank you very much for your help. I don't know if there is anything
that it would be good to do upstream as a result of this epic little
voyage ...

Richard

>  If you can find it,
> you could pass LDFLAGS=-lfoobar to ./configure.  My suspicion is that
> it's missing from your MXE build.  Another possibility is that 'regcomp'
> is a preprocessor macro in one of the include files, which the current
> tests would fail to detect.
> 
> > I am a bit out of my depth here ... these seem to be the libraries that
> > could plausibly provide regcomp(), )
> > (by running find . -name '*regex*' -print)
> > 
> > ./usr/i686-pc-mingw32/lib/libboost_regex-mt.a
> > ./usr/i686-pc-mingw32/lib/libwxregexu-2.8-i686-pc-mingw32.a
> > ./usr/i686-pc-mingw32/lib/libwxregex-2.8-i686-pc-mingw32.a
> > ./usr/i686-pc-mingw32/lib/libboost_regex-mt-d.a
> 
> These aren't the droids you're looking for.  Guile 1.8's ./configure
> seems to be looking for either libregex or librx, though I confess that
> my autoconf skills are weak.
> 
>   Mark





Re: define-macro syntax error

2013-02-12 Thread Andy Wingo
On Tue 12 Feb 2013 10:26, Daniel Hartwig  writes:

> On 12 February 2013 16:42, Andy Wingo  wrote:
>> On Tue 12 Feb 2013 09:15, Akop Pogosian  writes:
>>
>>> (define-macro when
>>>   (lambda (test . branch)
>>> `(if ,test
>>>  (begin ,@branch
>>>
>>> will give an error:
>>
>> This is a bug.  I just fixed it in stable-2.0; thanks for the report.
>
> Curious.  Is that some syntax from an older version, or …?

It was supported in 1.8.

Andy
-- 
http://wingolog.org/



Re: statically linking in srfi modules

2013-02-12 Thread Mark H Weaver
Richard Shann  writes:

> On Mon, 2013-02-11 at 12:03 -0500, Mark H Weaver wrote:
>> 
>> Can you find out where the 'regcomp' function is? 

> Well, I tracked back from the GNU/LilyPond build system - it seems to
> originate in glibc, but in the GNU/LilyPond build system it has been
> extracted out as a separate library. 
> http://lilypond.org/download/gub-sources/regex-2.3.90-1.tar.bz2
>
> By building this with --disable-shared I have obtained a library which
> links to guile and ice-9/regex is now working inside Denemo.

Excellent!

> Thank you very much for your help. I don't know if there is anything
> that it would be good to do upstream as a result of this epic little
> voyage ...

Glad to help, and thanks for letting us know how it went.

I guess the main thing for us to do upstream is to ensure that
--disable-shared works properly without such workarounds.  Fortunately
this is mostly not an issue in Guile 2, because the SRFI-1 and SRFI-60
libraries have been moved into the core.  The only remaining
dynamically-loaded extension bundled with Guile 2 is for readline.
It would be good to fix that at some point.

Regards,
  Mark



Re: statically linking in srfi modules

2013-02-12 Thread Ludovic Courtès
Mark H Weaver  skribis:

> I guess the main thing for us to do upstream is to ensure that
> --disable-shared works properly without such workarounds.  Fortunately
> this is mostly not an issue in Guile 2, because the SRFI-1 and SRFI-60
> libraries have been moved into the core.  The only remaining
> dynamically-loaded extension bundled with Guile 2 is for readline.
> It would be good to fix that at some point.

I don’t think it should be “fixed” because (1) it’s an optional feature,
and (2) it’s under the GPL whereas Guile is under LGPL.

Ludo’.