From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Random832 Newsgroups: gmane.emacs.help Subject: Re: why are there [v e c t o r s] in Lisp? Date: Fri, 16 Oct 2015 00:17:37 -0400 Message-ID: <87d1wfzbtq.fsf@fastmail.com> References: <87mvvjeg29.fsf@kuiper.lan.informatimago.com> <87io67pmr7.fsf@debian.uxu> <87mvvjzgup.fsf@fastmail.com> <87d1wfplu5.fsf@debian.uxu> <87a8rjea8m.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1444970053 32283 80.91.229.3 (16 Oct 2015 04:34:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 16 Oct 2015 04:34:13 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 16 06:34:04 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 1ZmwiQ-0002Ch-R3 for geh-help-gnu-emacs@m.gmane.org; Fri, 16 Oct 2015 06:34:02 +0200 Original-Received: from localhost ([::1]:50866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmwiP-0006V2-RD for geh-help-gnu-emacs@m.gmane.org; Fri, 16 Oct 2015 00:34:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmwT6-0003PK-Gb for help-gnu-emacs@gnu.org; Fri, 16 Oct 2015 00:18:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZmwT1-0005Qi-G8 for help-gnu-emacs@gnu.org; Fri, 16 Oct 2015 00:18:12 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:54220) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmwT1-0005QC-8t for help-gnu-emacs@gnu.org; Fri, 16 Oct 2015 00:18:07 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZmwSz-0001uZ-2c for help-gnu-emacs@gnu.org; Fri, 16 Oct 2015 06:18:05 +0200 Original-Received: from c-68-39-146-59.hsd1.in.comcast.net ([68.39.146.59]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 Oct 2015 06:18:05 +0200 Original-Received: from random832 by c-68-39-146-59.hsd1.in.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 Oct 2015 06:18:05 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 30 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-68-39-146-59.hsd1.in.comcast.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:ZjAHo6Nc9l+LtdMQN48yhvMcu7o= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:107672 Archived-At: "Pascal J. Bourguignon" writes: > Random832 writes: >> Well, what happens if you cdr that list? Does it make a >> copy? > > cdr'ing is no problem you just increment your pointer. > >> The thing is, if you can car a string people will wonder why >> you can't cdr it. And with mutable objects it's hard to make >> cdr work right. (fsvo "right") > > It's rplacd which becomes much more complex. You didn't mention my issue with "list of 5000 elements, cdr 4000 times" - does the garbage collector know to discard the first 4000 elements which are no longer reachable? > Also, when you program with such a system, you might be afraid that > rplacd leads to fragmented chains, and will have a tendency to call > copy-list to compact them. Hmm... can the garbage collector compact them? > But indeed, copy-list means that less > structure is shared, and therefore would waste time and memory. This is > what they do in C++ and why they believe lists are costly. Also with this kind of list I think you still lose the ability to have constant-time indexing, since you have to check every cell for the cdr bit.