From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Understanding `symbol??` macro from okmij.org Date: Thu, 14 Mar 2024 00:18:59 +0000 Message-ID: <9142ff20-0722-4fb7-b35a-7434e68d1777@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36503"; mail-complaints-to="usenet@ciao.gmane.io" To: Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Mar 14 01:19:48 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 1rkYp2-0009IN-9M for guile-user@m.gmane-mx.org; Thu, 14 Mar 2024 01:19:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkYoP-0005Xm-RA; Wed, 13 Mar 2024 20:19:10 -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 1rkYoO-0005XX-7X for guile-user@gnu.org; Wed, 13 Mar 2024 20:19:08 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkYoL-0000cu-LN for guile-user@gnu.org; Wed, 13 Mar 2024 20:19:07 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id E22ED240027 for ; Thu, 14 Mar 2024 01:19:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1710375541; bh=CWiNRvgBObweTvldugvcW+x05bxKUFLGWIvI68Ban4s=; h=Content-Type:Message-ID:Date:MIME-Version:From:To:Subject:From; b=exdGcp8XKLMALFQDolbGN6SlAUfF0PWdiACHR1RgrlafDp0jQFSJcBKnBAT2gxLrV j6qxDQ8b4lbl1nTJtpLCxX889MXE+jMk0XKX83dpRzHc5YegWaWGM18ZKzL8W/aHph KqzeTciUFd/7MD+7hiyCrrrUrKgA0iaTmb/oNlDZCVOa4ZMJYKU/4STmc3wQdXFsRX 2Im+V5KcbBqT3w3VsJxbd6qjYnHpw7Q982ODJ54u8Js/k/0Jv2CbQDWoW7VHBFCRh+ mxwNeETCX4ZMjWxCqeFTT/IPM+u4pz8OF2e1hzpqo8mIP1VePGpnSfUafGAlYWaM6t fekaWhHlVlMfQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Tw7KK2JY5z6tmv for ; Thu, 14 Mar 2024 01:19:01 +0100 (CET) Content-Language: en-US Received-SPF: pass client-ip=185.67.36.65; envelope-from=zelphirkaltstahl@posteo.de; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:19459 Archived-At: 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