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: Thu, 15 Sep 2016 02:58:20 +0200 Message-ID: <87zina568j.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> <87vaxywmh9.fsf@web.de> 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 1473901374 30712 195.159.176.226 (15 Sep 2016 01:02:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 15 Sep 2016 01:02:54 +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 Thu Sep 15 03:02:50 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 1bkL4e-0006wz-Oi for ged-emacs-devel@m.gmane.org; Thu, 15 Sep 2016 03:02:44 +0200 Original-Received: from localhost ([::1]:59420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkL4c-0007TL-Sw for ged-emacs-devel@m.gmane.org; Wed, 14 Sep 2016 21:02:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkL0b-000573-5q for emacs-devel@gnu.org; Wed, 14 Sep 2016 20:58:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkL0V-00077r-El for emacs-devel@gnu.org; Wed, 14 Sep 2016 20:58:32 -0400 Original-Received: from mout.web.de ([212.227.15.3]:50673) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkL0V-00076h-3f for emacs-devel@gnu.org; Wed, 14 Sep 2016 20:58:27 -0400 Original-Received: from drachen.dragon ([90.186.1.21]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0Mef0K-1bM3vS1cz2-00OF88; Thu, 15 Sep 2016 02:58:22 +0200 In-Reply-To: (=?utf-8?Q?=22Cl=C3=A9ment?= Pit--Claudel"'s message of "Wed, 14 Sep 2016 19:26:03 -0400") X-Provags-ID: V03:K0:/+au8KMIAJoG8dq0kf60XiyZqjrUKxGWUX/a3UCDsqaU3AmkATH A+knCF6WxkCEcTTasL3qa5HN51LMO7CbHQ7h61OEJTrP/hieJAFORwh9ZpG9RZqLXs4aGq8 iJIu/mHySB+spGdesXl6vP4rSSIXxowc7YC5JfpdY2e7HqINcWdPQLw8GA0wQO3q2aWCnPQ E/RcXSNIbbtL92CKq2TVw== X-UI-Out-Filterresults: notjunk:1;V01:K0:0IyKpYf10iI=:ql7HElEkBlPSld6jpaBNxX EsHj9Bugfh5SsFLhHlKPVCj8rRgWlEoCERxL9KvOUxGRbvoZEB6q+U+5IZ6tokkVV5DIcwSrW EjLrZFTz2/8vwWtqG0YccaEOuixVhmM5PaOISs9x8Qlve/I/4zdOr9Gm1L0NF41qwtPUfrWw/ HJucYzwDI9cvGBBs4WWtmt+FRGN9DcIVjsfddavWuffNjB6Q+3X8E5mXx043IDZdBEAyvdxK6 gam3u9CJ3ha6G0X6nvOotQkaDpgU0XXFjYdH1yCPoCAFry5Komjz6/DmQ81OJprWwL8nVVOBe xmUuvT4DY+fTFjadzipzoHpstNGuWKFpmyZONUisq75akGmotGCjAWS7YCGPdqUPt1LO8tYqs LYBWZavIv8mIkjYcWfFI3ydV5mzn8LePDn2Wv/oVQqHX3muLRBrNNvAf+JQHpKc0F9whnJCQu R6rGiCVZq7R9lUAvutIyUYRC2JwFyC+pr52y+bKtWf8BzzOWfbpwDwobum+sMw/lcuMOrWIle KqMwgpBEdc9aFnAt9unYNuIddtw7/8KLPDMbili0SRuatidc00k8K5RVL1jgSNm/bolXBy0dF 6l9VILrlJpCUgQF4Sm5gUyduvpCChdH6m3p5WNgc7tyQKcQscyctInLsmaetjYo7PmnJ8OQuE IOu8RToFqV5Uv5MHwv1NondJBH+39SvJnx3/HMeNNwRXNAkzgmc+WUz2Cr3NqIeKO5CjGidLI wOuhv4aWnla5E4MgvpWjWASVDfxKRH8NkE5cxXCmFcmDDHgV5zzTiYUZNieF0q5nkWcqVuIp X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.3 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:207437 Archived-At: Cl=C3=A9ment Pit--Claudel writes: > Ok, so we agree on this part :) Note that it may be nonsense to load > the file into a buffer, too; holding the full file in a list is more > or less as bad as holding the full file in a buffer. If the file is > large, that's very inefficient. Ok. But how do you refer to the file's contents from elisp, then? As a string? > > 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). > > Sure: if I have a stream of numbers, I may want to calculate the > average of the last n numbers. > Or if I have a stream of non-overlapping buffer spans, I may want to > remove just the last one. Sure, but with what I mean, the error (inefficiency) would already be in the "I have..." part. > To continue on the `last n lines' example, I may be interested in only > the last n lines of output of a running process (think dmesg | tail). As a string, right? Or in which way do you refer to the process output via streams? Can you please explain in short how you are using streams in your use case? (Sorry, I'm more a mathematician than a programmer, so it's not your fault if I miss the point). And should we add `stream' method implementations for building streams from files and/or processes to stream.el if such stuff is useful? But I guess I'm beginning to understand: if you have a string (or something "similar") consisting of multiple lines (or records or whatever), and you are interested in the last n lines, in contrast to a buffer, the "go to the end and then n times backwards" approach might not even be possible, so there is no alternative to dissect the complete string into entities from the start until you hit the end (and throw away most of the stuff without accumulation) -- i.e. to the sliding window approach implemented by seq-subseq with negative indexes. If there are such use cases in Emacs Lisp (with no more efficient alternative), you have convinced me that negative indexes would indeed be useful. Thanks, Michael.