From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations Date: Thu, 29 Sep 2016 01:19:04 +0600 Message-ID: References: <87twhbmwbx.fsf@web.de> <878tynl720.fsf@petton.fr> <8737onlapw.fsf@web.de> <87ziqu7ew9.fsf@petton.fr> <87mvmuxuyo.fsf@web.de> <8760tixi99.fsf@web.de> <87twh1kpem.fsf@web.de> <87y42r4d3a.fsf@web.de> <878tug9eh3.fsf@web.de> <87a8es6dcq.fsf@web.de> <87bmz7517d.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 1475090431 6079 195.159.176.226 (28 Sep 2016 19:20:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 28 Sep 2016 19:20:31 +0000 (UTC) Cc: Nicolas Petton , Emacs developers To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 28 21:20:26 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 1bpKP0-0000iM-G5 for ged-emacs-devel@m.gmane.org; Wed, 28 Sep 2016 21:20:22 +0200 Original-Received: from localhost ([::1]:60861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpKOy-0001jm-Vo for ged-emacs-devel@m.gmane.org; Wed, 28 Sep 2016 15:20:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpKO8-0001hd-04 for emacs-devel@gnu.org; Wed, 28 Sep 2016 15:19:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpKO6-00023E-2P for emacs-devel@gnu.org; Wed, 28 Sep 2016 15:19:26 -0400 Original-Received: from mail-lf0-x22c.google.com ([2a00:1450:4010:c07::22c]:35907) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpKO5-00022x-Qr for emacs-devel@gnu.org; Wed, 28 Sep 2016 15:19:25 -0400 Original-Received: by mail-lf0-x22c.google.com with SMTP id g62so62329918lfe.3 for ; Wed, 28 Sep 2016 12:19:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=TE2Lb3OArl8Z0u4IvBu+sT1HTWQuzy1NdcZ7UQxjQkE=; b=qQQyOgqj80sRGRhiOBuK2b6+RGylv0Qar4M+ewyHKBrKF8KrhYX2gPJ4Sziu2GkmEx 44qBtOK5AEraR/77FUhwBWCVlIwRrpQHDHhijsa55UfD1i6Z4/IHoiUoh3RA+bcOfHGF bS2Q2oQsGApJpUk+deMgbSWMPRVhoC8LCCUtraXvlP+JH1eWcGUmp/ZRRyLWOFLPSQ30 9V3Y20bYbhu6WszxNdHfroEuUg+6FzSYWG02payu/iaeR82A8PPAwyablmz/NAsc2x9h tnwJWlafurGAOMcg1132nuGtWg/sibRg+T/WDWu4VTxLKlbHjiQxGhufXxgI1x5mQDxf Kr4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=TE2Lb3OArl8Z0u4IvBu+sT1HTWQuzy1NdcZ7UQxjQkE=; b=PbMER+e3H0TJg02rh2mjNx+qZWhheX07GgyZ7nqsE9SyNWhRqKbPoQqkY6O9W9u6su /hnhsnWA77sov5ZhA2qVuuk6bULHsKWZEsFqDi1zyi1gA8KABGuJxfJv2U9E68rTbcp8 ybjtc2gnyLKF0S4giy6g4YL8UHh83Ypdi5wuZXzK6/wcyxyCDTJ0xs7E5/68UhpV5gHd nBOcj216PloBXTS3MleWNOEV6v98wm3oLPrAR9JYYmOX1t3VNwxyMD7YGzWTUgHpdJxw PvCEieaiO1bJV8XIHyQles8SxPvPxBwe7wT1SLaSNoRu0GRwfvKWB4dNbPp/1C7qe9Uy oM4w== X-Gm-Message-State: AA6/9RlaVm5blk8tSxjMdxfnKdye0LI8QmI4cQFa4ehKkQmvbqq7psVd6DYVC9swqDqU9Xh6vZ/43jk+x9wG0A== X-Received: by 10.46.71.85 with SMTP id u82mr3950249lja.19.1475090364897; Wed, 28 Sep 2016 12:19:24 -0700 (PDT) Original-Received: by 10.114.80.163 with HTTP; Wed, 28 Sep 2016 12:19:04 -0700 (PDT) In-Reply-To: <87bmz7517d.fsf@web.de> X-Google-Sender-Auth: -R9YjHpS2jekF3ihbhYTIN1ROdo X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22c 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:207875 Archived-At: On Thu, Sep 29, 2016 at 1:27 AM, Michael Heerdegen wrote: > I only partly understand your objection (what do you mean with "strict > in all elements"?). > > IMO, termination in every case is not a requirement, else, we would not > have `while'. Formulating algorithms to use streams is just a way to > describe loops. So I don't see why it would be a problem when stream > primitives potentially don't terminate. In lazy computations, an algorithm is said to be strict (or eager) with respect to its argument if it forces the computation of that argument=E2=80=99s value. Streams are in essence lazy lists. As such, they bring a new possibility to the table: while a list is limited by the available memory, a stream is potentially infinite. Solving algorithmic problems in terms of lists requires reasoning about termination. Yes, this is the same as with loops =E2=80=94 it=E2=80=99s just that loops force such re= asoning while with streams the issue is easy to overlook. >> As an example, if you want a subsequence starting at the first odd >> number or at index 1000, whichever is earlier, (seq-drop (min 1000 >> (seq-position-if 'odd S)) S) will not do the right thing. > > Would adding an optional argument that allows to specify an upper limit > for the indexes the function looks at cover (all of) your concerns? That was just an example. Real users will have other needs. If given a primitive that returns an index of something, they will try solving their problems in terms of that index. It is an interface that is easy to use incorrectly. But please do not let my theoretical concerns stop you from implementing useful things. A working implementation is the surest way of gaining collective experience about a tool.