From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.user Subject: Re: Macro to prepend element to list Date: Sat, 20 Mar 2021 17:04:56 +0100 Message-ID: <7fbe592f-2816-480d-86ca-3876277d2461@www.fastmail.com> References: <7e1286e7-3135-7747-9e25-395ffab3362e@abou-samra.fr> 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="11694"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.5.0-alpha0-206-g078a48fda5-fm-20210226.001-g078a48fd To: "Jean Abou Samra" , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Mar 20 17:06:51 2021 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 1lNe7m-0002vl-E7 for guile-user@m.gmane-mx.org; Sat, 20 Mar 2021 17:06:50 +0100 Original-Received: from localhost ([::1]:48070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNe7l-0005sl-95 for guile-user@m.gmane-mx.org; Sat, 20 Mar 2021 12:06:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNe6o-0005q7-Df for guile-user@gnu.org; Sat, 20 Mar 2021 12:05:50 -0400 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]:33009) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNe6k-0007D9-78 for guile-user@gnu.org; Sat, 20 Mar 2021 12:05:49 -0400 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 1292F5C0092; Sat, 20 Mar 2021 12:05:40 -0400 (EDT) Original-Received: from imap42 ([10.202.2.92]) by compute6.internal (MEProxy); Sat, 20 Mar 2021 12:05:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.se; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type:content-transfer-encoding; s=fm2; bh=Hjt7y NxZKEXqUIm+nWyYkmsfkISfg5XWL91smDWJqgw=; b=utQ3ALofFERYPFh8ue8qB l8v98CzcuwJ85tNwf5z9AcqQScSGnPHIi/dXM+YKgRLx9hl7cDb97ORoEb40uFz3 6ONvJfognz4LHRtd54Ek5xWlLcHnoqXfV3pUjmFZxfpgfnwOXFXJl5eIbN8kE8BM J7h0Fw9yhiI3Sb1SxFhgjdMCgfyGZexhUr35Vsy1/HNcJvDcZme5aKSUXWojAD7O +UQ4HlrV6/uSdChCYzaj7WBD+1Mt1ULZ/x74sc+DZk2KycUnqI7HWuMXTE7jxXLf h6zLbotlf/FZ9XzkvKc8pjyjNABxGFCWAEQupbWojrwvJh1Qo+dZEuNnzGcaEApM A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=Hjt7yNxZKEXqUIm+nWyYkmsfkISfg5XWL91smDWJq gw=; b=cZdBi7UlF1ubFIt8fCyuxS2+G2cwFkiCsMOweXVVqtYLfKfXOPvKveZt/ ZqHctlxaR85Kc8ebSuGXAb0Wyg5loyjmunIzLY1hRjo7Pe8MRaH+g7x7LTYEd40H +ZA+RKHUSITCbkAEqt3qKSYeYi1zETha3qOop24b6CF4BAKjJsoy4QgRceI24KLa uwanb74XJmP6k07c3uU30FMMegWbOZgrl0i4dGy05OZOJMerZAO8U4/GojzijjX1 fA1F6pnnIS3tkEn4fJ4Gt5/vxq+7osK6Z/2psap8x8/MlZ6Ng9zBuVdfTgVitYUC bc4YWPdnjiKZP2EoGEb9/38W/WpBA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegtddgjeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpefnihhn uhhspgeujhpnrhhnshhtrghmuceolhhinhhushdrihhnthgvrhhnvghtsehfrghsthhmrg hilhdrshgvqeenucggtffrrghtthgvrhhnpeekleevieevleejffetieeltdelkeevtedu heefheduieffffdttdegjeeihedtjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehlihhnuhhsrdhinhhtvghrnhgvthesfhgrshhtmhgrihhl rdhsvg X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6ACAE310005D; Sat, 20 Mar 2021 12:05:39 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <7e1286e7-3135-7747-9e25-395ffab3362e@abou-samra.fr> Received-SPF: pass client-ip=66.111.4.26; envelope-from=linus.internet@fastmail.se; helo=out2-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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=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-user@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.lisp.guile.user:17370 Archived-At: Well, mutating like that is not very common, except for maybe with alist= s. In which situations are you mutating the list like that? Usually you wou= ld build a reverse list using a recursive function and an accumulator, w= hich can be done without set! (which has a boxing overhead). --=20 Linus Bj=C3=B6rnstam On Sat, 20 Mar 2021, at 15:24, Jean Abou Samra wrote: > Hello, >=20 > I find myself frequently using the following macro: >=20 > (define-macro (prepend! thing lst) > =C2=A0=C2=A0 `(set! ,lst (cons ,thing ,lst))) >=20 > Have I missed a module somewhere that does this kind of things? > At least, I couldn't find anything in SRFIs. It may also be the > case that this is too specific to certain non-functional usages > (LilyPond in my case). >=20 > Thanks in advance, > Jean Abou Samra >=20 >=20 >