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:13: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="25309"; 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:21:35 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 1kogIg-0006TB-4D for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 14 Dec 2020 06:21:34 +0100 Original-Received: from localhost ([::1]:57824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kogIf-0003Vv-1r for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 14 Dec 2020 00:21:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kogAy-0001Fn-76 for help-gnu-emacs@gnu.org; Mon, 14 Dec 2020 00:13:36 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:58441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kogAv-0006mZ-OY for help-gnu-emacs@gnu.org; Mon, 14 Dec 2020 00:13:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1607922811; bh=4AdxuStP2Z0DcoUd29MEw0gVeKf4wfBPibdIFQ2n9G0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=M8sW7NNkvJ/CsNp1+s+q4X6mq2fHO7aDoGIpoRxHE+mjttdm51m5xbGX9GC+hYjU3 9hw9OuMYApNyegeKUzHKJuoAiZ0+dLRWJlAi/79IJPAaRpXG+Aia+QboDbmirQL4p/ mqeHVff0PDXlMmvjKvz9tBwzEP8ssqBUje1uuCRs= 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:13: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:Hwj9iB2/F1NE+8aB/3zCNBb24FHPVKl4/SYX0CR/P+JJTwoZjgKV5mMO3LcK+4GuN5Lnj i0sq5BLenXYmdYZ6r9AVG7z85XVfvlOGhioIetnPReM1jXu6cN/jSV0iPL0rYF0cZJQhQB1HnxQU nU+JVw1fAGWj25m9g9idkjX/zro1zGLMU89qijjsFQn9Vg/1ndYKvVe92NdmhiNmY1IshBPS/l85 hPQPEtmnycN5+zL4keWx+GVnIWehwtAfkQjya76/Izyc9bMI0zMh+nNYRt2a0t9sWB+v7Cfm1ELJ lM= X-UI-Out-Filterresults: notjunk:1;V03:K0:LGnVD9CbJII=:aX0jUvIfkKs6z0ONFz2Zpc z5z6m2Q6BWOvs8EweyefrXbS7aH67VTBsyL7szxrwvfukUk87OnyLbkIz19i1qFoBV/JFRuav jAH48Nkir1Gup+/6Q6yA3zPDidmMWHwYicoRyQHRDFYF9L8zLZvbXxto69dO9U9hyzX+PMJ07 o+Yg1tGyZN3Igk+oLm4V1VsHn1CdPARUSU9pmiOxIeEzAMmdmYSWFfLUQMwOK1I54fFG0wYIW 8NVCYh0rroFkzjp/Fr2DracOhNZoKywG96ROTENk43Q6+i11hxPUqDMDO6zgm3pqhKar0tWAH lkmxKqeX6lQ0hneLgBE+yOBXhA5ATwJELWqh2wrwauee2ozLyH+PLtEE/gmU5+vEXaLo4a7jc lhB3pHx46pBQdBHCFW/Y0dXrdDqh0Mh4Dp8O9YNXI23KFWFjzj5T6mI6VSj8VFGoCZ2B6F+lM roVXCKjx4ohc6lnucT+mJFfEsH+xpoNG7BMpnQDz+LuOFfzWtz6CMYhwySq4FqATTlgLsFJ12 hsKfTty9O8KKYwWjAo0pzyetMVuO+MmqPO6Os4oBNTlYfLesVNvh1MKGVV1GxKiRRLjEQus1p PfZRubHhrLufg= Received-SPF: pass client-ip=212.227.17.20; 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:126353 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 >=20 > 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! Yes, I have used "let" and "let*" to take a word and make frog over other words=2E=20 =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 >