* strange error message in macro
@ 2021-07-01 7:34 Damien Mattei
2021-07-01 8:02 ` Linus Björnstam
0 siblings, 1 reply; 2+ messages in thread
From: Damien Mattei @ 2021-07-01 7:34 UTC (permalink / raw)
To: guile-user
hello,
'begin' complains of 'sequence of zero expressions in form (begin)'
in:
scheme@(guile-user)> ($ {x <- 7} {y <- 8} (+ x y))
While compiling expression:
Syntax error:
unknown file:2:0: sequence of zero expressions in form (begin)
but:
scheme@(guile-user)> (begin )
make no error !
basically $ is a sort of begin macro that call :
(define-syntax %parse-assignment
(syntax-rules ()
...
if i wrote:
(define-syntax %parse-assignment
(syntax-rules (<-)
there is no more error:
scheme@(guile-user)> ($ {x <- 7} {y <- 8} (+ x y))
;;; <stdin>:5:0: warning: possibly unbound variable `x'
;;; <stdin>:5:0: warning: possibly unbound variable `y'
15
result is 15 and good!
i think that the explanation is with syntax-rules parameters not with
begin that would not accept zero expression in form , so why this strange
message?
i suppose i have trouble understanding the behavior and use of syntax-rules
parameters anyway and can not find any reliable documentation about it.
Damien
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: strange error message in macro
2021-07-01 7:34 strange error message in macro Damien Mattei
@ 2021-07-01 8:02 ` Linus Björnstam
0 siblings, 0 replies; 2+ messages in thread
From: Linus Björnstam @ 2021-07-01 8:02 UTC (permalink / raw)
To: Damien Mattei, guile-user
Begin in a Body is spliced into the body. Begin as an expression chain is not spliced, and needs at least one expression.
So: begin in definition context (directly in function bodies and at top-level) can have 0 expressions. Begin in other contexts must have at least one expression.
--
Linus Björnstam
On Thu, 1 Jul 2021, at 09:34, Damien Mattei wrote:
> hello,
> 'begin' complains of 'sequence of zero expressions in form (begin)'
> in:
> scheme@(guile-user)> ($ {x <- 7} {y <- 8} (+ x y))
> While compiling expression:
> Syntax error:
> unknown file:2:0: sequence of zero expressions in form (begin)
> but:
> scheme@(guile-user)> (begin )
> make no error !
> basically $ is a sort of begin macro that call :
> (define-syntax %parse-assignment
> (syntax-rules ()
> ...
>
> if i wrote:
> (define-syntax %parse-assignment
> (syntax-rules (<-)
> there is no more error:
> scheme@(guile-user)> ($ {x <- 7} {y <- 8} (+ x y))
> ;;; <stdin>:5:0: warning: possibly unbound variable `x'
> ;;; <stdin>:5:0: warning: possibly unbound variable `y'
> 15
> result is 15 and good!
>
> i think that the explanation is with syntax-rules parameters not with
> begin that would not accept zero expression in form , so why this strange
> message?
> i suppose i have trouble understanding the behavior and use of syntax-rules
> parameters anyway and can not find any reliable documentation about it.
>
> Damien
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-01 8:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 7:34 strange error message in macro Damien Mattei
2021-07-01 8:02 ` Linus Björnstam
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).