From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 0BABCqPzSWM65gAAbAwnHQ (envelope-from ) for ; Sat, 15 Oct 2022 01:41:23 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id YNzwCaPzSWPsLQAAauVa8A (envelope-from ) for ; Sat, 15 Oct 2022 01:41:23 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A80162FEFB for ; Sat, 15 Oct 2022 01:41:22 +0200 (CEST) Received: from localhost ([::1]:40592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ojUIr-00065J-SL for larch@yhetil.org; Fri, 14 Oct 2022 19:41:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojUIS-00064Y-TZ for help-guix@gnu.org; Fri, 14 Oct 2022 19:40:56 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:54521) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojUII-00082n-22 for help-guix@gnu.org; Fri, 14 Oct 2022 19:40:56 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id D73823200915; Fri, 14 Oct 2022 19:40:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 14 Oct 2022 19:40:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= philipmcgrath.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1665790840; x= 1665877240; bh=Z0Bb1942snm7jSUxVTOe88Q0DPYt94o9UKWk4yJBqTo=; b=m EOHYsoopCTSJ5sLlTmkgc0/gYqH/qJJeyRLfXyAP87lNYsT0Aek9MzI8EaouWX52 nDts+XusjH9B5iVVeEfsrJnYNG6s1im1i69XlEJBR+UZRQQhvKCKRL62ITTx5FLd IjAOTDEKP3FqyCEXQ6tamh4sZ/nI85Lr8BBRwLLKhpk4stKKa1r2fZH8nyhnwDAc 8arV6cC4QiHHU54rB+rS6MIK9z8UYvaQtWQCkOuc20gwvqL3oN3kfdPpD6rLZzEr Q0wWhDbd86nz50WpPMskBd5md5XY3k1lEg0XXYNYNfOwpWsLA6PHUpGm/aszUIG4 i8QCQ41nSdbcixUNfr3Lw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1665790840; x=1665877240; bh=Z0Bb1942snm7jSUxVTOe88Q0DPYt 94o9UKWk4yJBqTo=; b=h4vuNTPzuIXkjnExKR50hz3q4YJohCAmVE8AEeim9Y+1 0gApQ0NNBFdKr4sk5S0x9dysBcesBH8SOrwYBb7v+bx61kGht/OfzFNZjXIKxDEO To+08SXEXHO4Z0xbJnpiiramObEd3ruqyMXXnPBYkvQOg+wMyed3d2JG1/nTTd+s Rq6V/QN7eCLjIxmESaX0v42+ZUybaQjImuuIEP1G9gDzAMIkzVny82d9dkjrTavG zG0Da2n48WSGeJ41f2k0GoWG5ZaRWHXhCopx1doe/wkD4Q6lJ5tOnUnh759yWzcf 1UvoxcWqmqM2n8D5jF5cdFwSmpl4pVH7ipny49OpnA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekfedgvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhushhpvggtthffohhmrghinhculdegledmnecujfgurhephffvvefufffkjghfgggt sehgtderredttddvnecuhfhrohhmpefrhhhilhhiphcuofgtifhrrghthhcuoehphhhilh hiphesphhhihhlihhpmhgtghhrrghthhdrtghomheqnecuggftrfgrthhtvghrnhepjeei kedvvdelueehvedthfevjeegtdevgfejtddvjedvheejteevjeeiteeuudejnecuffhomh grihhnpehgohhoghhlvgdrtghomhdprhgrtghkvghtqdhlrghnghdrohhrghdphihouhht uhgsvgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehphhhilhhiphesphhhihhlihhpmhgtghhrrghthhdrtghomh X-ME-Proxy: Feedback-ID: i2b1146f3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 14 Oct 2022 19:40:39 -0400 (EDT) From: Philip McGrath To: jgart , help-guix@gnu.org Cc: Guix Help , "(" Subject: Re: Don't Unquote Me Date: Fri, 14 Oct 2022 19:40:31 -0400 Message-ID: <3721504.MHq7AAxBmi@bastet> In-Reply-To: References: <20221013230326.GC30936@dismail.de> <20221014133807.GB14915@dismail.de> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1958187.taCxCBeP46"; micalg="pgp-sha512"; protocol="application/pgp-signature" Received-SPF: pass client-ip=64.147.123.19; envelope-from=philip@philipmcgrath.com; helo=wout3-smtp.messagingengine.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: "Help-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1665790882; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Z0Bb1942snm7jSUxVTOe88Q0DPYt94o9UKWk4yJBqTo=; b=t3MN3cx9/5nfuWBpY0pSCiOMXIjB6A2X817VPPyBuo0OxzS5s0CBJEKzWyeE43KhmBhatq z2bva+n9KapMBI+cKOeFDhSb7zfDaACJiOtvKYw4FnaDJ74x0WyUdwASgymDJXCd0HvQdr q8C2WiFViUIwPkbmOZQabDXE2Rzrkuff/CJ7i5JtkTdJj20z75OVyIs18fOqugYFYrVcnm FFK3joMGsL8yEqeVVc6lrCWh1V8i/zEng9DNeA9fmzJo6iJrLM6BsXaQuNUnQrdnqh3iN5 0NZd8h4RldKvUBwPoczyoKeu15wlHYmv3mHpr1QwG+mOz/0kO8mOtfXMey+plA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665790882; a=rsa-sha256; cv=none; b=rcjQpYE2NUUWPyA1AFQ1SxTGrBv4A4Njc5llKb5031M574tJ0TxjbmltwHtViFUzzA1osJ 5WKlCiWcDh/PG0Aokmxk2i58E/Fs4+zgpPypGmdvlte3pgTPmwFJ5jYCH2WoKdtQdJscq6 o3ENc3FxRtTVnkrpF7Yp6OHfc0OXo6GstragiHH49HmepR1zBdfqk17wzncBaMxQQRtFiS 6Ji+8RbwtU0Wzf0v6p9OVKVeFkSlNW6cTl59zL5+RmV2pQuOjsFHWuxq+WnLBFeOqlDIMk sUGwBKXPhTOL6gSU0HdaMJPgZkgh3wUhh0phM8lLxGr+nlYbtakFV9ROSJM0pA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=fm3 header.b="m EOHYso"; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm3 header.b=h4vuNTPz; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 1.11 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=fm3 header.b="m EOHYso"; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm3 header.b=h4vuNTPz; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: A80162FEFB X-Spam-Score: 1.11 X-Migadu-Scanner: scn1.migadu.com X-TUID: pCco6B/sbefr --nextPart1958187.taCxCBeP46 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii"; protected-headers="v1" From: Philip McGrath To: jgart , help-guix@gnu.org Cc: Guix Help , "(" Subject: Re: Don't Unquote Me Date: Fri, 14 Oct 2022 19:40:31 -0400 Message-ID: <3721504.MHq7AAxBmi@bastet> In-Reply-To: On Friday, October 14, 2022 3:32:55 PM EDT ( wrote: > On Fri Oct 14, 2022 at 7:38 PM BST, jgart wrote: > > > Nope; they're special built-in forms like ``lambda'' and ``define''. > > > > So, they are ordinary functions defined in guile? > > > > Or by built-ins you mean that they are implemented in C? > > > > I'll read through the guile source code a bit later ;() > > They are fundumental forms. You cannot define ``quote'' et al in terms of > any other feature. Just like there's no way to implement ``lambda'' in > Guile, because ``lambda'' is a fundumental form. So yes, they will be > implemented in C as part of the Guile core. > Well, `quasiquote`, `unquote`, and `unquote-splicing` can straightforwardly be defined as macros in a simpler core language that provides `quote`. That's how they are implemented in Racket. You can find the source, which is fairly close to portable Scheme, in: --8<---------------cut here---------------start------------->8--- less $(guix shell racket-minimal -- racket -e '(display (collection-file-path "qq-and-or.rkt" "racket/private"))') --8<---------------cut here---------------end--------------->8--- The only reason the implementation is a bit verbose is that is at quite an early step in building `racket/base` from the primitive `#%kernel` language understood by the core compiler and runtime system: the same file contains the implementation of `let`. (Similarly, you need one of `lambda` or `case-lambda` to be primitive, but not necessarily both.) The situation with `quote` is a bit trickier because `quote` encompasses a few different features. In practice, most languages in the Scheme family choose to implement `quote` as a primitive syntactic form (including Racket [1]), but many of its features, even those that seem quite magical, could be implemented as derived constructs with a sufficiently expressive macro system. For example, here's a portable implementation of the part of `quote` which creates a symbol corresponding to some syntactic identifier: --8<---------------cut here---------------start------------->8--- #!r6rs (import (rnrs)) (define-syntax quote-symbol (lambda (stx) (syntax-case stx () ((_ id) (identifier? #'id) #`(string->symbol #,(symbol->string (syntax->datum #'id))))))) (write (quote-symbol hooray)) --8<---------------cut here---------------end--------------->8--- You could get the right allocation behavior either by relying on "The Guaranteed Optimization Clause of the Macro-Writer's Bill of Rights"[2] or by using a macro system that provides functions like `syntax-local-lift-expression`[3]. The implementation above relies on the base language having a built-in notion of string literals, which feels a little like cheating because we typically explain the concept of literals in terms of `quote`. Indeed, in `#lang racket/base`, the expression: "hooray" expands to: (#%datum . "hooray") which then expands to: (quote "hooray") where the expander introduces `#%datum` with the lexical context of `"hooray"` to provide languages a means of hygienically interposing on the meaning of literal data. In other words, self-quoting literals are not primitive in Racket. For some deep thoughts along these lines, I highly recommend this mailing list post by Ryan Culpepper, who designed Racket's `syntax-parse`: https://groups.google.com/g/racket-users/c/HaSmcTN0SA4/m/1XYa-mL5AgAJ Returning to the original question, regardless of all of the above, you can tell that `quote` et al. can't be functions, primitive or derived, because of how evaluation works in Scheme-like languages. As an example, consider the expression: (quote (hello world)) If `quote` were bound to a function, to evaluate that expression, we would need to first evaluate `hello` and `world` and then apply the value of `hello` to the value of `world`. We'd then apply the value of `quote` to the result. Obviously that doesn't work: an essential aspect of `quote` is that it doesn't evaluate its subform. -Philip [1]: https://docs.racket-lang.org/reference/syntax-model.html#%28part._fully-expanded%29 [2]: https://www.youtube.com/watch?v=LIEX3tUliHw [3]: https://docs.racket-lang.org/reference/stxtrans.html#%28def._%28%28quote._~23~25kernel%29._syntax-local-lift-expression%29%29 --nextPart1958187.taCxCBeP46 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE9GWrrNY3rqwUFVXPygNjjfo/HHoFAmNJ828ACgkQygNjjfo/ HHoc1BAAjNzcPUggyewon9WQKgfYUO4kkdL81pQEIvdg3Pz7+rIapH5DIlxhNhmY R0+OnwqmYILDL+BLC/aSB5Bn5MAg2VsuA9fIyciasyBol18BMtPM7h5gq+PYJVuR fjuSrVZHJN/rBAKaPCSc+DAdInK2v+643WrumAkVTfDENxxr5S6ErcuQhzC9eWba /SZ2qSSCi0RVoHG6VgKe0kVp9hQOOLbTBc3Z4148nKkR+K84o/1uU5oNhPDE2GGT 87qFz7dlRCmmDDBis1l/HrgSRB4yxEBvCUk51Enc4rAU0sei67xqlWsSV0PmHnwQ I3RysMQcCDtOYfVtnNUdUYMBPJI22GN+g6fb1Nr11cVMjFIuHeNmN2ByQUpJGt5h 6VYQoQeJXjiQtWUSHfyg0AjcgSoEpOjHJ7kT6yLG1I/AI6ygdJDFsTxcdo0+06mv wBD478UEf2FF8RGF5q2WCoOTPhabbsNHLYFBlCQdJ+etKo192HaXtU0FTZQ8+Pel RiqagaNaKZ6ISE+bmKKCw3t4BkqKviYFFOytAdHQQW0RVeWnL5mtugMdalY0wKcG zCZPMvI6fdTa8Y+6Djhf0o+fjyfuCevMFqTIH0sGYnozU3lShF04yExK1UKU3/9y baEUQ2bkbpebciM8FtuoLFoKJ9GVxl8JTLIDRoHFEvn2D50nwXA= =T/6l -----END PGP SIGNATURE----- --nextPart1958187.taCxCBeP46--