guile-user
[Top][All Lists]
Advanced

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

Re: macro syntax-error works in prefix but not curly-infix


From: Zelphir Kaltstahl
Subject: Re: macro syntax-error works in prefix but not curly-infix
Date: Sun, 19 Sep 2021 12:34:27 +0000

Hi Damien!

I think there might be too few expressions matched in the first case: (_ var
expr). Wouldn't it have to be:

~~~~
(_ var expr1 expr2)
;; or
(_ var exprs ...)
~~~~

for

~~~~
(<+ var expr1 expr2)
~~~~

to work, simply because of the number of expressions there?

But then you might need to use ellipsis in the resulting syntax somewhere,
otherwise you get:

~~~~
syntax: missing ellipsis in form (syntax (define var expr))
~~~~

I don't know where that would go, but I also do not understand yet the goal. I
think it is best to always describe, what you want to achieve, when you write a
macro.

Regards,
Zelphir

On 9/4/21 4:41 PM, Damien Mattei wrote:
> hi,
>
> i have this macro:
>
> (define-syntax <+
>   (syntax-rules ()
>     ((_ var expr) (define var expr))
>     ((_ err ...) (syntax-error "Bad <- form")) ;; does not work in infix !
>     ))
>
> why my syntax-error pattern never reach in infix:
>
> scheme@(guile-user)> {x <+ 7 8}
> While compiling expression:
> Syntax error:
> unknown file:3:3: source expression failed to match any pattern in form <+
>
> but ok in prefix:
>
> scheme@(guile-user)> (<+ x 9 10)
> While compiling expression:
> Syntax error:
> unknown location: <+: Bad <- form in form (<+ x 9 10)
>
> why?
> Regards,
> Damien

-- 
repositories: https://notabug.org/ZelphirKaltstahl



reply via email to

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