From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip McGrath Newsgroups: gmane.lisp.guile.devel Subject: Re: The Guile junk drawer and a C plea Date: Sat, 29 Jun 2024 17:53:21 -0400 Message-ID: References: <20240629002027.13853-1-richard@freakingpenguin.com> <20240629124128.hNhS2C00S3x6CSs01NhTmA@xavier.telenet-ops.be> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15574"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: Richard Sent , guile-devel To: Maxime Devos , "mikael@djurfeldt.com" , "Thompson, David" Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sat Jun 29 23:54:07 2024 Return-path: Envelope-to: guile-devel@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 1sNg1E-0003pt-I2 for guile-devel@m.gmane-mx.org; Sat, 29 Jun 2024 23:54:05 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNg0k-0004WG-Lm; Sat, 29 Jun 2024 17:53:34 -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 1sNg0e-0004Vx-Jd for guile-devel@gnu.org; Sat, 29 Jun 2024 17:53:32 -0400 Original-Received: from fhigh6-smtp.messagingengine.com ([103.168.172.157]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNg0c-0004wC-8S for guile-devel@gnu.org; Sat, 29 Jun 2024 17:53:28 -0400 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 92C181140193; Sat, 29 Jun 2024 17:53:24 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sat, 29 Jun 2024 17:53:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= philipmcgrath.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1719698004; x=1719784404; bh=66yjm3GPn/ zYJ+zD7ygOn9IPyYQjtqCLFIa4kYSoMlY=; b=h3WKMzsQLOqEvTEbzvtmHkv0Aa EH7nD6+fsofSBw/lc2UXhEYjj5rdnV9o83/E6/259CpKUjLPKc1fSNRjGTjtx1k/ /daPQhcjFfdrk43Pb/x1bgWsQ6wW0LA+/zByx82Xv88x3rmMmgKdRaLc64ReJ8dT B7YpAT9e8hqhLAyMB4PCKlYfz1ZPYp8rE8zKMFBg1wVWSdXxA7YHfpsb4YNIk6EO FxXZC/oYoqytWv/vTMVr4NJvanQhUFK7v/8zra1chm2t04L/IJCgSz/MTbB7QC3z /hnXB7Y4POOJQ4MzvxIWJldfOBUt0xxolLweVz7gld0P1sXGnKInltdlmx0A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1719698004; x= 1719784404; bh=66yjm3GPn/zYJ+zD7ygOn9IPyYQjtqCLFIa4kYSoMlY=; b=G DagpPxTFLl9wtSPZsXIWP9BvNYqsNmo9Rx2mRjEYpJTDItuibrUYPRxFUigb/SwY BA01hNQK8nqSRoI7DSMEXfQJ2mtJER2UYSoJMTAbf5pbflUBunSKbIEMHHAuWt2Y Z59sj3LjCECgnBYZwYxdyjaF1ZlUyKJK1HK1PQj1uI10HDjpPgHVIjXpuOcz6xSs 2GoAOfexQgYRC4Y2Fbemc7soYfgkZ9TTwT+Sz2iyf3FGF6SQgIiHx/sO/lPxKxbL EfTAy5jwTQKfaizshBtkl/yUk9qwQwz8Ew4UmqYV4YHIm4yx3++nCI9rLIWDHu3g 8dKZZLkJ9SXwWkr89MBCg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddtgddtgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeenucfhrhhomheprfhhihhl ihhpucfotgfirhgrthhhuceophhhihhlihhpsehphhhilhhiphhmtghgrhgrthhhrdgtoh hmqeenucggtffrrghtthgvrhhnpeetveetgfdvhedvleejudduledugeffudfhieejudef geejieefffdufeeghfdthfenucffohhmrghinhepfihinhhgohhlohhgrdhorhhgpdhgnh hurdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mhepphhhihhlihhpsehphhhilhhiphhmtghgrhgrthhhrdgtohhm X-ME-Proxy: Feedback-ID: i2b1146f3:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 29 Jun 2024 17:53:23 -0400 (EDT) Content-Language: en-US In-Reply-To: <20240629124128.hNhS2C00S3x6CSs01NhTmA@xavier.telenet-ops.be> Received-SPF: pass client-ip=103.168.172.157; envelope-from=philip@philipmcgrath.com; helo=fhigh6-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22512 Archived-At: Hi, On 6/28/24 22:52, Thompson, David wrote: > First, I think Guile's default environment is a total mess. It's > the very definition of a junk drawer. There's over 1000 names in > the (guile) module! Contrast this with R7RS-small's (scheme base) > module that only has 200ish. Guile is an old project and I'm sure > stuff just accumulated over the years, but having so much in the > default environment makes it hard to know what a program actually > uses because many things that ought to be explicit imports are not. > This makes it a challenge to move Guile in a more "least authority" > direction. As a rule, I think Guile should *not* add any additional > names to the default environment without an extremely good reason. > Because (guile) is imported implicitly, new names can cause clashes > with existing code that require #:replace to suppress the warning > about shadowing core bindings. For example, the newish 'spawn' > procedure collides with 'spawn' in (goblins core) in the Goblins > project. I think Guile needs a (multi-year, multi-major version) > plan to deprecate cruft and move the good stuff into different > modules. Give a hoot, don't pollute (the default environment)! On 6/29/24 06:41, Maxime Devos wrote: > > The default environment is irrelevant to most Scheme libraries, since > it is irrelevant to any library defining modules with > ‘define-module’, ‘define-library’ or ‘library’ forms (which is pretty > much the only reasonable way to define modules unless you are making > your own system). This already reduces a lot of compatibility > concerns. An important exception is anyone doing ‘eval’ or compiling > expressions (think anyone doing the equivalent of “guile -l > script.scm”. > Unfortunately, the "default environment" in the sense of "core bindings" definitely is relevant to libraries using `define-module`. For example, in this module: ``` (define-module (foo) #:export (foo)) (define foo (cons 'a 1)) ``` at least the bindings for `define`, `cons`, and `quote` are implicitly imported from `(guile)`. R6RS libraries don't have this problem. If instead you write: ``` #!r6rs (library (foo) (export foo) (import (rnrs base)) (define foo (cons 'a 1))) ``` the bindings for `define`, `cons`, and `quote` are explicitly imported from `(rnrs base)`. If the `import` clause were empty, you would get unbound identifier errors. (The report specifies the meaning of `library` and its `export` and `import` sub-forms, but it also specifies that they are not bound by any of the libraries specified by the report, though `library` is often implemented as a binding in some sort of implementation-specific start-up environment that is not in scope inside a library.) Similarly, in the Racket module: ``` (module foo racket/base (provide foo) (define foo (cons 'a 1))) ``` the module's language, `racket/base`, is explicitly the source of the binding for `provide` as well as those for `define`, `cons`, and `quote`. If you replaced `racket/base` with `typed/racket/base` or `lazy`, you would get a valid module with different meanings for those bindings. Of course, you could avoid some indentation by writing the above as: ``` #lang racket/base (provide foo) (define foo (cons 'a 1)) ``` Andy Wingo's "lessons learned from guile, the ancient & spry" () concludes in part: > But as far as next steps in language evolution, I think in the short > term they are essentially to further enable change while further > sedimenting good practices into Guile. On the change side, we need > parallel installability for entire languages. Racket did a great job > facilitating this with #lang and we should just adopt that. I agree. Obviously `#lang` does much more than this (we Racketeers tend to say `#lang` as shorthand for a bunch of complementary but mostly independent features), but I think a particularly important aspect is that each module should explicitly specify its "language"/"default environment"/"core bindings". If done well, this actually *avoids* the compatibility concerns some have raised: when you want to make a breaking change, you pick a new name, and things using the old name keep working, interoperably. I wrote some thoughts about how Guile could gradually adopt `#lang` in a way that would provide for future compatibility in a sub-thread on this list last year: https://lists.gnu.org/r/guile-devel/2023-02/msg00075.html My long-term pipe dream (though I have no particular plans to work on it), inspired by conversations with Christine, would be a grand, interoperable unification of Guile and Racket based on `#lang` and linklets: https://lists.gnu.org/archive/html/guix-devel/2021-10/msg00010.html and, earlier, https://lists.gnu.org/archive/html/guix-devel/2021-08/msg00099.html Philip