From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73431: Add `setf` support for `stream.el` in ELPA Date: Sat, 05 Oct 2024 09:32:26 -0400 Message-ID: References: <827cc7fc-10be-4b93-bd67-f275193e5d84@protonmail.com> <068ecfc3-b452-49a8-89bb-f42012aea5d4@protonmail.com> <6caa1395-a3b2-4e70-b905-1cbfee0f92bd@protonmail.com> <87y138hjij.fsf@web.de> <875xqa8fby.fsf@posteo.net> <932d7782-5685-4a43-b34c-fc0bb3a958e4@protonmail.com> <87zfnk6ydj.fsf@posteo.net> <9db72ab8-604e-451d-b9a0-74fa5b3fa81f@protonmail.com> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37546"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Michael Heerdegen , Philip Kaludercic , Nicolas Petton , 73431@debbugs.gnu.org To: Okamsn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 05 15:33:17 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1sx4uL-0009cB-6V for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 05 Oct 2024 15:33:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sx4u4-00041R-Nw; Sat, 05 Oct 2024 09:33:00 -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 1sx4u2-00041E-L3 for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2024 09:32:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sx4u2-0007iT-CK for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2024 09:32:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=0eQNdbFIJk4Qt2TQchF6Gv2Gd+6E1TKF4QMov88xE4c=; b=VRsC2cPz0R1WGpl1oKjO/vIpAyMrCcElJcLe++B3IWF895k9NaO7+sGPx17asImofTCAytwp0BfZ80sld75lpXB90j3XVqqB1rSN08RHdU5F1GcgqCtAVfwwoqsZKURRSXrkb0XPRoLB8NhsEbf5mQh9AyL68C4BUbgVVgyamNNm3oM8Z64q9A+SvGQ6Bcxg9hO1cqdb5//16KpMMrfoWt/XbKrxUMS7DMMF0J5OkzjO7lO9vyqSeEZg+ACjuVa3b7YM8ad6FyWK226bJ5KRiA9inQesg+7mOfDnVwJNijg5X713Ucs4c+maq5Qz/LIJ4nZBZDn+LOLToco5jJGB0w==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sx4u6-0007hh-HL for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2024 09:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 05 Oct 2024 13:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73431 X-GNU-PR-Package: emacs Original-Received: via spool by 73431-submit@debbugs.gnu.org id=B73431.172813516529584 (code B ref 73431); Sat, 05 Oct 2024 13:33:02 +0000 Original-Received: (at 73431) by debbugs.gnu.org; 5 Oct 2024 13:32:45 +0000 Original-Received: from localhost ([127.0.0.1]:37489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sx4to-0007h5-Sp for submit@debbugs.gnu.org; Sat, 05 Oct 2024 09:32:45 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:29081) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sx4tj-0007gn-Fy for 73431@debbugs.gnu.org; Sat, 05 Oct 2024 09:32:42 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 149BB100043; Sat, 5 Oct 2024 09:32:29 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1728135148; bh=dHIcSHCq793zlmYVmn/4qK2z5gHLEGcKeifXl5+DNSU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=eBdNFCcc25BbUhGARg6UerS9v2CWE5RymFgzqzalVr4txM7uuv3/X5FanNiAW//fJ XBHEaAQ9L0Nd/bdKHCyS0LozQE/DM75XT7ubFfAt9z0Bep/Z0D9z6U0b849LwKU/nU 33PlcDDe5V6Ln2fji3b59sqJzDd8nmmOtYUeWkaz86D+CX8ERA8bGMr2SOIKLANHCv ZR9IIu7kVoilL2Z+++V6PZwjdH2DVHJhfWVdnpqb252oIRWuARmlzauA7eMz62ZrEL sSvoNbfTf31qxrThaqtazMcup0sLoP9CEpDnnD0ZtTNMWe0z83IwAV8CZwCD7+LQ3n u2v94+RNJMWmw== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 2A10E10002E; Sat, 5 Oct 2024 09:32:28 -0400 (EDT) Original-Received: from pastel (unknown [216.154.14.167]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D2A9E120387; Sat, 5 Oct 2024 09:32:27 -0400 (EDT) In-Reply-To: <9db72ab8-604e-451d-b9a0-74fa5b3fa81f@protonmail.com> (okamsn@protonmail.com's message of "Sat, 05 Oct 2024 02:44:18 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:293036 Archived-At: > +(cl-defstruct (stream (:constructor stream--make-stream) > + (:predicate streamp) > + :named) > + > + "A lazily evaluated sequence, compatible with the `seq' library's func= tions." > + > + (evaluated--internal > + nil > + :type boolean > + :documentation "Whether the head and tail of the stream are accessibl= e. > + > +This value is set to t via the function `stream--force' after it > +calls the updater function.") > + > + (first--internal > + nil > + :type (or t null) > + :documentation "The first element of the stream.") > + > + (rest--internal > + nil > + :type (or stream null) > + :documentation "The rest of the stream, which is itself a stream.") > + > + (empty--internal > + nil > + :type boolean > + :documentation "Whether the evaluated stream is empty. > + > +A stream is empty if the updater function returns nil when > +`stream--force' evaluates the stream.") > + > + (updater--internal > + nil > + :type (or function null) > + :documentation "Function that returns the head and tail of the stream= when called. Instead of funny field names, I recommend you use something like `(:conc-name stream--)` so all the automatically-created accessors have a "--" in their name, declaring them internal. Also, I wonder: have you tried to stick closer to the original code, with a structure like (cl-defstruct (stream ...) (evald nil :type boolean) (data nil :type (or function list))) Was it worse than what you have? Stefan PS: We could even be nasty and do things like: (cl-defstruct (stream ...) (data nil :type (or function list))) (cl-defstruct (stream--unevald (:include stream))) (cl-defstruct (stream--evald (:include stream))) and then use (aref STREAM 0) to dynamically change the type from `stream--unevald` to `stream--evald` to avoid storing the `evald` field. =F0=9F=98=88