From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: steve-humphreys@gmx.com Newsgroups: gmane.emacs.help Subject: Re: Appending to a list Date: Mon, 14 Dec 2020 06:28:31 +0100 Message-ID: References: <877dpljtwg.fsf@fastmail.fm> <87sg89v1f7.fsf@telefonica.net> <87mtyhxovn.fsf@zoho.eu> <871rftxlwl.fsf@zoho.eu> <87czzdyqra.fsf@web.de> <873609vvmg.fsf@zoho.eu> 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="16022"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: moasenwood@zoho.eu Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 14 06:39:21 2020 Return-path: Envelope-to: geh-help-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 1kogZs-00043w-GD for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 14 Dec 2020 06:39:20 +0100 Original-Received: from localhost ([::1]:49398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kogZr-0006od-In for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 14 Dec 2020 00:39:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kogPU-0006pG-9t for help-gnu-emacs@gnu.org; Mon, 14 Dec 2020 00:28:36 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:46059) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kogPR-0008Ks-Ma for help-gnu-emacs@gnu.org; Mon, 14 Dec 2020 00:28:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1607923711; bh=R0quKJHFDUR2lXf2WmAjSNMTqSB91Zooz/ntcIK7jk8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=bxMorkfWZIhxGyepElt0WEdGdPFBaRmfYr94fLTtsVmqCiKau9wzi4unYVjvET1B9 N/KeKb4JvfwRSlCCuH0t4PHQHFtYBmtJOIBcvqUDz2cOQisgXvzthtQX8e791/RWST NehNORS6quBOFGEaVBsNK9216UMIJVtckt1/5UJk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs09.server.lan [172.19.170.177]) (via HTTP); Mon, 14 Dec 2020 06:28:31 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <873609vvmg.fsf@zoho.eu> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:ULUSdKZsNYwaZH+fOM5HXFJLhEuxlc8mGRHzg3UbJLJc3aAzo9OoW0kQaNJuQrZEe3T/c aLhkpdAQbmSADdRLMURheYLsO0kb8kPxzM+/q9mTJzprtANv0ZvfY+xNOqmneAjfYsfwV9hK679l fXwkSsPXIL3o/09OTpDhI2zKx5IXRofuKiYos3a1fFu0CZLcVWqPcTXEC6XUeL2cfjMYsZeO/42k DxJ6osC9UpzZU4G9qr20Ry3qIO0cVWPtCoXTqPDgR39BJ0ec6ftA2BbR1j5aCCUmvWpogm+Nqzz1 yA= X-UI-Out-Filterresults: notjunk:1;V03:K0:zrC0MOxzR8I=:uCOtg2mmR/RpcG1l2e9F4e XbltooLxdoYfit382D3iV7PE6SG1mhEdHJIEMKC2a0SZElms5RwKYO+zwnsiGVeBaxa6RSW6n CysU6sfB+gc2iWbGQw1mEQ/Mjf/346mNqvcoUyxvp7WFTygVZbxn1meeYrvAFXjV8qJj8uXv/ YI4WrOfyOybzdmOEjWHgpdHAvV1xwo9I5tZKirQQ8H5Ph2Rsrs4f/Mh13Bfery/Ji/AaAizn0 Exxg11yh1jpA49Vw6+jb3xwo1W8rWK3dRM2zVR9MS6MJYSuQvlVP2cUY5gCJmkc0R+mCOE26F azJscmInu1ExQ3vfIvwoGzsp/n13vOmGo7j3hF4ZDi8YXiz6Cvavw2X0Sxxj4q8mPJ89BCmcE v4dcENf7qfNHFJ6zlynFtkQoJlW+LOSYHjjYeBE6g2aWzNgN6L/U5jGTrpmbBKXU7lsmJ2ly8 qWUPQF521JIf2ZscJCJ2dvKPDYdaG4MjJSTbmge7B8s5zzSQ5sy+uo7yyRk8/GyisrfERBEx/ hyiRCSqokH5b0QVLY4HId9bp8k4wuINxMYi4D6MKpHEagV17VJdwBV6/bfY4cD1v8u+VC1gif pMrgRzeXFzXZE= Received-SPF: pass client-ip=212.227.15.18; envelope-from=steve-humphreys@gmx.com; helo=mout.gmx.net 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:126354 Archived-At: > Sent: Monday, December 14, 2020 at 5:50 AM > From: "Emanuel Berg via Users list for the GNU Emacs text editor" > To: help-gnu-emacs@gnu=2Eorg > Subject: Re: Appending to a list > > steve-humphreys wrote: >=20 > > I thought I could push element by element=2E >=20 > You can, you can push whatever, if that data structure makes it > more involved solve it for onee pilot case, then write a small > `defun', put it there, and ever after just pass the single > element to that=2E >=20 > > I got inspiration from some discussions here that push is > > more efficient and wanted to have a go=2E Yes, I do use push to > > make the larger list=2E Have not thought about defvar before=2E > > I have read that "setq" does not introduce a variable, but > > I would need some explanation about that=2E >=20 > It works with `setq' only without `defvar' the byte-compiler, > which should always be used BTW, without it the byte-compiler > will complain=2E I have not understood the paragraph above=2E > Comment-out the defvars in this >=20 > (require 'cl-lib) >=20 > (defvar bird-list-all) > (defvar bird-list-1) > (defvar bird-list-2) >=20 > (setq bird-list-all '()) >=20 > (setq bird-list-1 '("Western jackdaw" "European goldfinch")) > (setq bird-list-2 '("rook")) >=20 > (cl-pushnew bird-list-1 bird-list-all) ; (("Western jackdaw" "European g= oldfinch")) > (cl-pushnew bird-list-2 bird-list-all) ; (("rook") ("Western jackdaw" "E= uropean goldfinch")) >=20 > and the byte-compiler will say >=20 > geh=2Eel:=20 > In toplevel form: > geh=2Eel:193:7: Warning: assignment to free variable =E2=80=98bird-lis= t-all=E2=80=99 > geh=2Eel:195:7: Warning: assignment to free variable =E2=80=98bird-lis= t-1=E2=80=99 > geh=2Eel:196:7: Warning: assignment to free variable =E2=80=98bird-lis= t-2=E2=80=99 > geh=2Eel:198:13: Warning: reference to free variable =E2=80=98bird-lis= t-1=E2=80=99 > geh=2Eel:198:25: Warning: reference to free variable =E2=80=98bird-lis= t-all=E2=80=99 > geh=2Eel:199:13: Warning: reference to free variable =E2=80=98bird-lis= t-2=E2=80=99 >=20 > In more ambitious projects, like a package, e=2Eg=2E [1], defvar > should be used also to make available documentation, both in > the code and for the on-line help which in practice is the same > thing - Emacs is self-documenting, remember? >=20 > Heh, not really, right? But still, do it=2E >=20 > Anyway, don't rely too much on variables, defvar or no defvar=2E > Better to rely on defuns and use `let' and `let*' there=2E IMO! >=20 > [1] https://dataswamp=2Eorg/~incal/emacs-init/buc=2Eel >=20 > --=20 > underground experts united > http://user=2Eit=2Euu=2Ese/~embe8573 > https://dataswamp=2Eorg/~incal >=20 >=20 >