guile-user
[Top][All Lists]
Advanced

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

Re: Understanding `symbol??` macro from okmij.org


From: Olivier Dion
Subject: Re: Understanding `symbol??` macro from okmij.org
Date: Thu, 14 Mar 2024 10:52:46 -0400

Excuse my ignorance, by why is symbol?? not written using syntax-cases
and the `indentifier?' guard?

On Thu, 14 Mar 2024, Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> wrote:
> Hello Guile Users!
>
> I am having trouble understanding how the `symbol??` macro from 
> https://okmij.org/ftp/Scheme/assert-syntax-rule.txt works.
>
> Here is what I have so far:
>
> ~~~~start~~~~
> ;; (symbol?? FORM KT KF)
> ;; FORM is an arbitrary form or datum.
> ;; A symbol? predicate at the macro-expand time.
> ;; Expands in KT if FORM is a symbol (identifier), Otherwise, expands in KF.
> ;; KT: Continuation/Case in case of true.
> ;; KF: Continuation/Case in case of false.
> (define-syntax symbol??
>    (syntax-rules ()
>      ;; The check is done by first pattern matching against some other
>      ;; forms, that are not a symbol.
>      ((symbol?? (x . y) kt kf) kf) ; It's a pair, not a symbol
>      ((symbol?? #(x ...) kt kf) kf) ; It's a vector, not a symbol
>      ;; After those things are excluded, the thing might be a symbol.
>      ((symbol?? maybe-symbol kt kf)
>       (let-syntax ((test
>                     (syntax-rules ()
>                       ((test maybe-symbol t f) t)
>                       ((test x t f) f))))
>         (test abracadabra kt kf)))))
> ~~~~~end~~~~~
>
> So I don't understand why `test` works or how it works to check, whether 
> `maybe-symbol` is a symbol or not. And I don't understand how `abracadabra` 
> helps with that, or why it helps, to pass something undefined.
>
> Can someone help me understand, what is going on there?
>
> Actually I am trying to understand the whole page, and I got there while 
> looking 
> for a good `assert` macro ... rabbit hole and all that.
>
> Best regards,
> Zelphir
>
> -- 
> repositories:https://notabug.org/ZelphirKaltstahl
-- 
Olivier Dion
oldiob.ca



reply via email to

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