* define-macro syntax error
@ 2013-02-12 8:15 Akop Pogosian
2013-02-12 8:20 ` Daniel Hartwig
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Akop Pogosian @ 2013-02-12 8:15 UTC (permalink / raw)
To: guile-user
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?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: define-macro syntax error
2013-02-12 8:15 define-macro syntax error Akop Pogosian
@ 2013-02-12 8:20 ` Daniel Hartwig
2013-02-12 8:42 ` Andy Wingo
2013-02-12 10:11 ` Ian Price
2 siblings, 0 replies; 7+ messages in thread
From: Daniel Hartwig @ 2013-02-12 8:20 UTC (permalink / raw)
To: Akop Pogosian; +Cc: guile-user
On 12 February 2013 16:15, Akop Pogosian <apogosian@gmail.com> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: define-macro syntax error
2013-02-12 8:15 define-macro syntax error Akop Pogosian
2013-02-12 8:20 ` Daniel Hartwig
@ 2013-02-12 8:42 ` Andy Wingo
2013-02-12 9:26 ` Daniel Hartwig
2013-02-12 10:11 ` Ian Price
2 siblings, 1 reply; 7+ messages in thread
From: Andy Wingo @ 2013-02-12 8:42 UTC (permalink / raw)
To: Akop Pogosian; +Cc: guile-user
On Tue 12 Feb 2013 09:15, Akop Pogosian <apogosian@gmail.com> 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/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: define-macro syntax error
2013-02-12 8:42 ` Andy Wingo
@ 2013-02-12 9:26 ` Daniel Hartwig
2013-02-12 10:00 ` Akop Pogosian
2013-02-12 14:07 ` Andy Wingo
0 siblings, 2 replies; 7+ messages in thread
From: Daniel Hartwig @ 2013-02-12 9:26 UTC (permalink / raw)
To: guile-user
On 12 February 2013 16:42, Andy Wingo <wingo@pobox.com> wrote:
> On Tue 12 Feb 2013 09:15, Akop Pogosian <apogosian@gmail.com> 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 …?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: define-macro syntax error
2013-02-12 9:26 ` Daniel Hartwig
@ 2013-02-12 10:00 ` Akop Pogosian
2013-02-12 14:07 ` Andy Wingo
1 sibling, 0 replies; 7+ messages in thread
From: Akop Pogosian @ 2013-02-12 10:00 UTC (permalink / raw)
To: Daniel Hartwig; +Cc: guile-user
On Tue, Feb 12, 2013 at 3:26 AM, Daniel Hartwig <mandyke@gmail.com> wrote:
> On 12 February 2013 16:42, Andy Wingo <wingo@pobox.com> wrote:
>> On Tue 12 Feb 2013 09:15, Akop Pogosian <apogosian@gmail.com> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: define-macro syntax error
2013-02-12 8:15 define-macro syntax error Akop Pogosian
2013-02-12 8:20 ` Daniel Hartwig
2013-02-12 8:42 ` Andy Wingo
@ 2013-02-12 10:11 ` Ian Price
2 siblings, 0 replies; 7+ messages in thread
From: Ian Price @ 2013-02-12 10:11 UTC (permalink / raw)
To: Akop Pogosian; +Cc: guile-user
Akop Pogosian <apogosian@gmail.com> 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"
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: define-macro syntax error
2013-02-12 9:26 ` Daniel Hartwig
2013-02-12 10:00 ` Akop Pogosian
@ 2013-02-12 14:07 ` Andy Wingo
1 sibling, 0 replies; 7+ messages in thread
From: Andy Wingo @ 2013-02-12 14:07 UTC (permalink / raw)
To: Daniel Hartwig; +Cc: guile-user
On Tue 12 Feb 2013 10:26, Daniel Hartwig <mandyke@gmail.com> writes:
> On 12 February 2013 16:42, Andy Wingo <wingo@pobox.com> wrote:
>> On Tue 12 Feb 2013 09:15, Akop Pogosian <apogosian@gmail.com> 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/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-02-12 14:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-12 8:15 define-macro syntax error Akop Pogosian
2013-02-12 8:20 ` Daniel Hartwig
2013-02-12 8:42 ` Andy Wingo
2013-02-12 9:26 ` Daniel Hartwig
2013-02-12 10:00 ` Akop Pogosian
2013-02-12 14:07 ` Andy Wingo
2013-02-12 10:11 ` Ian Price
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).