From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Elpa: Pinpoint semantics of `seq-subseq' for streams Date: Wed, 14 Sep 2016 17:05:22 +0200 Message-ID: <87vaxywmh9.fsf@web.de> References: <87bmzrahvg.fsf@web.de> <79c6ccd6-9808-f4fd-071a-58559f72ecdc@gmail.com> <8737l3a4ab.fsf@web.de> <27962aa1-ae40-99f8-64ad-ae21012fb36e@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1473865635 31943 195.159.176.226 (14 Sep 2016 15:07:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 14 Sep 2016 15:07:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: emacs-devel@gnu.org To: =?utf-8?Q?Cl=C3=A9ment?= Pit--Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 14 17:07:10 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkBm6-0006OQ-SN for ged-emacs-devel@m.gmane.org; Wed, 14 Sep 2016 17:06:58 +0200 Original-Received: from localhost ([::1]:56668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkBm4-0007ez-Uw for ged-emacs-devel@m.gmane.org; Wed, 14 Sep 2016 11:06:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkBkl-0007b7-IV for emacs-devel@gnu.org; Wed, 14 Sep 2016 11:05:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkBke-00015w-Nl for emacs-devel@gnu.org; Wed, 14 Sep 2016 11:05:34 -0400 Original-Received: from mout.web.de ([212.227.15.14]:51902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkBke-00015Y-D4 for emacs-devel@gnu.org; Wed, 14 Sep 2016 11:05:28 -0400 Original-Received: from drachen.dragon ([90.186.1.88]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0MTxxp-1bb0gW2me1-00QkHC; Wed, 14 Sep 2016 17:05:26 +0200 In-Reply-To: <27962aa1-ae40-99f8-64ad-ae21012fb36e@gmail.com> (=?utf-8?Q?=22Cl=C3=A9ment?= Pit--Claudel"'s message of "Tue, 13 Sep 2016 21:24:34 -0400") X-Provags-ID: V03:K0:+iWhUMvxu5YVNgtLsLKHlbRYZraTfKo9hKEYi68Q268XsPSUuoR VWU1TBDp9l/w7VXwVPhEAF5tw9mqH7y9eLQuzaShoa7ieMAG4/yBLAigwG/IKqBGCO92qjL zEzcLnMSKLYcGP6wtvKaXSp1AhCjUAx5zrB5UabVuUadTfHOIoOg3f4mNzffrP0G/yf/78x BEweyAA2Jke2lmCU9BRMA== X-UI-Out-Filterresults: notjunk:1;V01:K0:8avxMd5/Nbk=:BIlm0Z5Xwnrz8IUU5nHogZ fLq4PaDr/tR1vYV06Nvk2MQWYQCc2GIvsE4BNSQ3jqReqMtXS5VdiLGg2yzvnFG77vNL/3/eB m15qc7Sxl1oe+uQMiNuk9n4Kb/7BdwodPhE0qZcVH7Q8syfPrDwpCrlsC4Az1ej0Liv0RoRfE +BQiNhU7fpdZJOZYodkfZ/jz2draY5qYY4bnKcBMmlEViu8M/Rfpn6yJJJO+TWMxqLAxJJZL0 IagK+gHFouAzTq7ggciQCO0og+5DeBW7TQRXthOLuR/Fgv3d8+iPr5UWZrJBernMCsfMYDROl uCsYYo+T0+4QRwh11Hb6T4y4wHUlWxtmuz3fgr3pkJz60ZpwJ7VtmLofkdqdTp3f1bgrXQdVP 3NBxC0NKDA71mzjYcP9egJ/74IiH9wS3dzP7cMVrUB1z2XCuuUuWJDQvqJgnAMWtNkjH/8Fth J0os/p0L4V+0xm2/HEQp6ud8KI80XudqEffuebKw9mC8GMEFMkZi7U1g75NzLy/u4iywCUlCC gcOf5TtU6VJSuPS/BS7WTCRle4kASpvTc1c1ticlcLf6QLPr4e2+Qii5B8lBnxR+pQYH2KnlF 2vGyCz+8Asa/pdyOmRYEfQIffuZL7MSnmR1YqUUc0K5szDuT7VXPUEnmM8CF6LF6T0SO13B1V OK8ULmYy9tinD8phC5UDFtWWrkkESMiaSd12Bb0Xc9TE2bs/Nff9j26ZclTHYLu3G4hG7hmwq NVYgFCgNKS4dOkxmGqaswPTxWmaelOcENV0+urL+lVfZR7cj5lxQDdXDBmBqe9+uY3vHG+tq X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.14 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207432 Archived-At: Cl=C3=A9ment Pit--Claudel writes: > I don't think converting to list would be a good idea. When operating > on text files, for example, it's often convenient to get the last n > lines of a file. If the file is represented as a stream of lines, > then tail makes sense. Doesn't it? Converting the file to a list of > lines beforehand sounds like a bad idea, memory wise. Indeed, in this case, it would be nonsense to convert into a list. > I don't see why; isn't it common to implement slyding-window-style > algorithms on data streams? 'tail' is just one such example. Do you have an example where this would be useful for streams in Emacs, different from the "last n lines" one (see my comment about that below). > Let me know what you think of the 'last n lines of a file' example. I think this is actually a very good example why it is good to forbid negative indexes. If you are interested in the last n lines of a file, why would you dissect the complete file (or buffer) into lines and throw away nearly all of the result? In Emacs, if you dissect a buffer into its lines, this can take seconds if the buffer is a bit larger (no matter if you collect the lines in a data structure or just throw the result away). If you are interested in the last n lines, this is potentially unlimited inefficient. Instead, go to the end of buffer, go back N lines, and start building a stream from there. So, in this case, in my opinion forbidding negative indexes would have saved you from the error of writing bad code. Negative indexes would be an invitation to write bad code. Maybe it would be better to provide that semantics in a separate function, so that the programmer is forced to think about what he is doing. WDYT? Regards, Michael.