Re: syntax? in scheme/Guile

Damien Mattei <[email protected]>
Newsgroups gmane.lisp.guile.user
Message-ID <CADEOadeDrN=-Otb1oE3S=UmQN_+_Z8Bz2zVRmoHGKZo=OomOuw@mail.gmail.com>
thank you Dave,

syntax? is enough for the operators like #'* #'+ etc that i  need to test
(even if some complex syntax object are returned #f) :
scheme@(guile-user)> (use-modules (system syntax))
scheme@(guile-user)> syntax?
$1 = #<procedure syntax? (_)>
scheme@(guile-user)> (syntax? #'(2 * 3))
$2 = #f
scheme@(guile-user)> #'(2 * 3)
$3 = (#<syntax:unknown file:6:3 2> #<syntax:unknown file:6:5 *>
#<syntax:unknown file:6:7 3>)
scheme@(guile-user)> (syntax? #'*)
$4 = #t
scheme@(guile-user)> (syntax *)
$5 = #<syntax:unknown file:8:8 *>
scheme@(guile-user)> (syntax? *)
$6 = #f

regards,
damien

On Tue, May 14, 2024 at 1:43 AM Thompson, David <[email protected]>
wrote:

> Hi Damien,
>
> On Mon, May 13, 2024 at 4:43 AM Damien Mattei <[email protected]>
> wrote:
> >
> > any idea for a predicate for syntax object in Guile/scheme like exist in
> > Racket 'syntax?' ?
>
> This predicate is in the (system syntax) module in Guile.
>
> > - what is a wrapped syntax object?
>
> Syntax objects are part of the syntax-case procedural macro system. A
> syntax object wraps a value with things like lexical context and
> source location (when available).
>
> For example:
>
> scheme@(guile-user)> (call-with-input-string "(1 2 3)" read-syntax)
> $16 = #<syntax:unknown file:1:0 (#<syntax:unknown file:1:1 1>
> #<syntax:unknown file:1:3 2> #<syntax:unknown file:1:5 3>)>
>
> See 6.8.3 Support for the ‘syntax-case’ System in the manual.
>
> Hope this helps,
>
> - Dave
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.