From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: `append' vs. `nconc' Date: Thu, 31 Dec 2015 10:22:53 +0100 Message-ID: <20151231092253.GA19900@tuxteam.de> References: <568164D8.6050700@ojkastl.de> <87io3iyr7t.fsf@debian.uxu> <87si2kezg1.fsf@mithlond.arda> <87a8osrlj4.fsf_-_@debian.uxu> <87lh8bgafa.fsf@mithlond.arda> <877fjve0x5.fsf@kuiper.lan.informatimago.com> <87wprvqnco.fsf@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; x-action=pgp-signed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1451555886 4103 80.91.229.3 (31 Dec 2015 09:58:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 31 Dec 2015 09:58:06 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 31 10:58:00 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aEZzb-0005IB-Qi for geh-help-gnu-emacs@m.gmane.org; Thu, 31 Dec 2015 10:58:00 +0100 Original-Received: from localhost ([::1]:55221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aEZzb-0007PQ-2c for geh-help-gnu-emacs@m.gmane.org; Thu, 31 Dec 2015 04:57:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aEZzQ-0007PL-Ja for help-gnu-emacs@gnu.org; Thu, 31 Dec 2015 04:57:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aEZzN-0001Nx-D5 for help-gnu-emacs@gnu.org; Thu, 31 Dec 2015 04:57:48 -0500 Original-Received: from mail.tuxteam.de ([5.199.139.25]:59605 helo=tomasium.tuxteam.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aEZzN-0001Np-7E for help-gnu-emacs@gnu.org; Thu, 31 Dec 2015 04:57:45 -0500 Original-Received: from tomas by tomasium.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1aEZRd-0005LY-Gg for help-gnu-emacs@gnu.org; Thu, 31 Dec 2015 10:22:53 +0100 In-Reply-To: <87wprvqnco.fsf@debian.uxu> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 5.199.139.25 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:108549 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thu, Dec 31, 2015 at 05:00:07AM +0100, Emanuel Berg wrote: > "Pascal J. Bourguignon" > writes: > > >> OK, so for example this: (setq > >> completion-ignored-extensions (append > >> completion-ignored-extensions '(".bcf" ".run.xml")) > >> ) Is better as: (nconc completion-ignored-extensions > >> (list ".bcf" ".run.xml")) ? > > > > No. You should never use nconc only for effect (just > > like delete, etc). > > What do you mean by "effect"? Side effect, the big lurking Monster for functional programmers: (defvar foo 15) (defun monster () (setq foo 42)) (monster) ;; now foo is 42: Gaaah! (message "%S" foo) Nconc has a side effect: after calling it, many of the lists are changed. Side effects make things more "interesting", because now things depend on the order of evaluation of things: it does matter, e.g. wheter you evaluate the arguments of a function (call) left-to-right or right-to-left (or random!). Things like that. The equivalent in C might be int i = 42; printf("%d %d %d\n", i++, i++, i++) or the classic: a[i] = i++; (which leads to undefined behaviour, because compiler writers need some wiggling room to make efficient compilers!). Sometimes you call functions because you *want* the side effect (aka "calling for effect"), as in (message "Happy New Year!") So-called "pure functional languages" have to go towards some "interesting" contortions for that. Regards - -- tomás -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlaE8+0ACgkQBcgs9XrR2kYE0QCfcFXQTDijDWoh4GQKerTVEuuw ragAn2SMKqwM3yfp5LQQt5MLQAEgdMjV =iPp+ -----END PGP SIGNATURE-----