From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: Appending lists Date: Thu, 17 Jun 2021 09:48:43 +0200 Message-ID: <20210617074843.GD16310@tuxteam.de> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="fOHHtNG4YXGJ0yqR" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30165"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.5.21 (2010-09-15) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 17 09:49:51 2021 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 1ltmmd-0007Zf-NW for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Jun 2021 09:49:51 +0200 Original-Received: from localhost ([::1]:37580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltmmc-000413-OQ for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Jun 2021 03:49:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltmld-0003zY-3w for help-gnu-emacs@gnu.org; Thu, 17 Jun 2021 03:48:49 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:35535) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.90_1) (envelope-from ) id 1ltmlZ-0003Le-Uk for help-gnu-emacs@gnu.org; Thu, 17 Jun 2021 03:48:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:Date; bh=wI2XI8E9/o+WsvHz3O3PalO9JBBb72aPCtIpAQvRdiE=; b=mTmQ8C8/Q7ldDa4JAqm3sBdTOgYWVZAo+Q2tP6pRCQVXToq07rI3q6LlqE++mB8YheRw3Vb7HuCgQ3MgTeKXiM5x5hUYZHVR9Lxd0ENlCxCFK/hxra3ct/Cwv+eomdv79yhKjd72kw1Jz/DYM8kqgph9rOodZPBQr3+67TooVYN+jhBM72ZOvdmwVDonypjn5LcUFSlSrwIYSk3CM1T8AF0utCzPoI6/1DpLaYBoFOUblYAlL6sfw0BRJddBGXff0iL4ofnyhpI2RNvXvJmWxB+CEvgQIrh1j+JFGH3LkhHAyQstLUdDzmsJR8rYKcO459HLIMOWSq9nLARoCxk2Hw==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1ltmlX-0004wY-5b for help-gnu-emacs@gnu.org; Thu, 17 Jun 2021 09:48:43 +0200 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, 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:130958 Archived-At: --fOHHtNG4YXGJ0yqR Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 17, 2021 at 03:18:48AM +0000, Drew Adams wrote: > > >> What's a "deep copy"? [...] > > deep copy =3D actual copy > > shallow copy =3D copy of references? >=20 > Did you read `C-h f copy-tree'? >=20 > No. Everything involving list structure (conses) > uses references. >=20 > `copy-sequence' is a shallow copy [...] All this shows that "shallow" and "deep" are relative. Copy-tree is "as deep as it gets", with some consequences. Let's do an experiment, shall we? But before: save all your texts. And, if Emacs behaves strangely, C-g usually gets you out of the thickets. So put on your lab coat and your security goggles. For an awesome experience, best do your session interactive, step by step: (setq lst '(a b c d dacapo)) =3D> (a b c d dacapo) =20 (cddddr lst) =3D> (dacapo) ;;; OK, it's the last one. =20 (setcdr (cddddr lst) lst)) ;;; make circular list [1] =3D> (a b c d dacapo a b c d dacapo a . #5) ;;; uh, whatever (see below [= 2]) =20 lst =3D> (a b c d dacapo a b c d dacapo a . #5) ;;; (see below [2]) =20 (setq otherlst (copy-tree lst)) ;;; TIGHTEN YOUR GOGGLES! =3D> ... ;;; [3] As I said above: you (most probably) can get your Emacs back with C-g. Cheers [1] https://en.wikipedia.org/wiki/Ouroboros [2] We have a circular list. This funny #5 you see there is print's way to tell you "hey, I've been here already. Are you trying to pull my leg?". Its behaviour depends on the variable `print-circle', which, when true, makes print even smarter -- in our case it's nil, but it seems that for simple cases like this one, print sometimes doesn't explode. Hold on to your goggles at step 3, just in case... [3] Copy-tree, alas, isn't as smart. It will happily fill your memory if you don't hurry up with your C-g. - tom=C3=A1s --fOHHtNG4YXGJ0yqR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAmDK/lsACgkQBcgs9XrR2kYzxACfctgSZuCNUY07hBLfeOqTnTyP s8oAn040x5iVjqEAKiBuC3jpgT7cOldO =xUk3 -----END PGP SIGNATURE----- --fOHHtNG4YXGJ0yqR--