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:55:48 +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="6445"; 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:56:19 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 1kogqJ-0001Xv-A4 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 14 Dec 2020 06:56:19 +0100 Original-Received: from localhost ([::1]:35752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kogqI-00052t-BT for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 14 Dec 2020 00:56:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kogps-00051D-UK for help-gnu-emacs@gnu.org; Mon, 14 Dec 2020 00:55:52 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]:52941) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kogpq-0002v6-92 for help-gnu-emacs@gnu.org; Mon, 14 Dec 2020 00:55:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1607925348; bh=tsvVF0RiMQ8wtfEGAtCxS/zYs1x755bF0um3ctme6C8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=fFLojXSNmUJUxRUXVPtypeRsh8FZ4GPd1Du19WzNz0KxDg6qn40pVfbNytbSZnJMk HfhN+jn6paw1f8Gso3MDruAzCxYJB31O3+p4rTBZn/QbRklO+0nwyrOGx6dnHJPXsP 8D5tAfKTswD6TdkJo0AX/RBuTLHYH/V+WqLHjWvc= 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:55:48 +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:aJQIErM7rKBz3ISWFSSHwVvEeU9m/zx/G8wb/m2f044kI7EBj6vAOqF0VFgsTnZqBRSEY 3tZIkZ58ZfbCMqONCqcLOd7ia6woYmPiJXm0XW6eFjs46Jf9OLku+Ko89aGkC25YZfnztg8qoK5P Rxfi6+dt55HdG2hFBFFZy+6eRu6l0KT1tEmrPmysT66iqS5VFdx6EAL9yKOqZ1p8w3uvaXQgB6Q/ g5FuT+V6uoX3VIQpSDuj9fUHAJ2+vv1wzhjxSAXsgIKmdUn7YzBN95avDL5Ue9TGomuxrrML5OtY WY= X-UI-Out-Filterresults: notjunk:1;V03:K0:rQ3I0T52D2g=:gBPOAd66gYsV1uAG2+J5NE kNboLzzk/0l5yslCpMNmmy+oYs8KTjbrVJtdrTSd1gfxnEpIhnh2r67rNfWGDrpmp/727fFkM LEFHHCXjJlZydlEXOeGgaYAFUCT9Wxhvupoh7mY1d+rds9vHqtSyf93tv+D/mSmq/n3RpEr1i FgIHlySpWBZ+Fm5tOhVBjlEWiTUHFp0bQkcm68oKVN5EFlQFdgE6Q+BFmSls3+ab9gkWZBN5P JlG44KptgHIZhf0+YdbzfWooqpzfPx6V94iRUjpENWGK8iOQSRPDaFO8UFaVt9KRa+UfXaS1I dFwN9o1soL+tVvi+Vlgwx2R7qeTrxxY8f16I/Abt+WUNbtVxGXg8gxpSKTpBg1cBxnFGi8qh7 uY5MOb64U5VXFRNcCBGXYiSKAbEEbToRh3OWkWdffNtR8xqympuIig+kPEFS2hE62AS6W7xO1 AfASMsFXwvxDTYxe7MRQlsIZI+YxfYDiiKEgSBQpS8WHcTfzbGG57ZHBO5oV1akgil3UG9gWW K0C4RHXaZl5fw2+j+fJDfvNyuX2xo5Heb+OVNrKL84mk/LuDUcIOYr/15k1QcMk8mygLkqBzy h5g6sOVuyYvIg= Received-SPF: pass client-ip=212.227.15.15; 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:126355 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 Do you mean that by commenting the defvars and using "setq", the compiler will complain because no variables were defined by bird-list*=2E =20 defvar can only be assigned if they have not been set and have a documentation string=2E But when do you decide betweenh setq=20 and defvar? =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")) Is the problem with the compiler occurring because of cl-pushnew? =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 >