From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Olivier Dion Newsgroups: gmane.lisp.guile.user Subject: Re: Understanding `symbol??` macro from okmij.org Date: Thu, 14 Mar 2024 10:52:46 -0400 Message-ID: <87sf0sx3up.fsf@laura> References: <9142ff20-0722-4fb7-b35a-7434e68d1777@posteo.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11943"; mail-complaints-to="usenet@ciao.gmane.io" To: Zelphir Kaltstahl , Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Mar 14 15:53:28 2024 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkmSW-0002rI-LV for guile-user@m.gmane-mx.org; Thu, 14 Mar 2024 15:53:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmS5-0005DK-3z; Thu, 14 Mar 2024 10:53:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmS3-0005DB-BK for guile-user@gnu.org; Thu, 14 Mar 2024 10:52:59 -0400 Original-Received: from smtp.polymtl.ca ([132.207.4.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmS1-0005z5-5e for guile-user@gnu.org; Thu, 14 Mar 2024 10:52:59 -0400 Original-Received: from localhost ([209.209.33.179]) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 42EEqkWb028323; Thu, 14 Mar 2024 10:52:51 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 42EEqkWb028323 In-Reply-To: <9142ff20-0722-4fb7-b35a-7434e68d1777@posteo.de> X-Poly-FromMTA: ([209.209.33.179]) at Thu, 14 Mar 2024 14:52:46 +0000 Received-SPF: pass client-ip=132.207.4.11; envelope-from=olivier.dion@polymtl.ca; helo=smtp.polymtl.ca X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19463 Archived-At: Excuse my ignorance, by why is symbol?? not written using syntax-cases and the `indentifier?' guard? On Thu, 14 Mar 2024, Zelphir Kaltstahl 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