guile-user
[Top][All Lists]
Advanced

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

Re: syntax? in scheme/Guile


From: Damien Mattei
Subject: Re: syntax? in scheme/Guile
Date: Tue, 14 May 2024 09:39:42 +0200

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 <dthompson2@worcester.edu>
wrote:

> Hi Damien,
>
> On Mon, May 13, 2024 at 4:43 AM Damien Mattei <damien.mattei@gmail.com>
> 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
>


reply via email to

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