From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.org!.POSTED!not-for-mail
From: Philipp Stephani
Newsgroups: gmane.emacs.bugs
Subject: bug#26338: 26.0.50; Collect all matches for REGEXP in current buffer
Date: Sat, 08 Apr 2017 14:41:29 +0000
Message-ID:
References: <8737dr6kxx.fsf@calancha-pc> <87h926cvgl.fsf@localhost>
<87k272ow7g.fsf@calancha-pc> <87fuhpcbem.fsf@localhost>
<87lgrheyvn.fsf@calancha-pc>
<87pogsmefn.fsf@jane>
<874ly3vw1p.fsf@users.sourceforge.net>
<943bd0fd-c4ad-48f4-a803-f832b5bf0edf@default>
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a114b30ec7e5e13054ca8bd19
X-Trace: blaine.gmane.org 1491662544 29527 195.159.176.226 (8 Apr 2017 14:42:24 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 8 Apr 2017 14:42:24 +0000 (UTC)
Cc: 26338@debbugs.gnu.org, npostavs@users.sourceforge.net,
Marcin Borkowski , Juri Linkov
To: Tino Calancha
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 08 16:42:15 2017
Return-path:
Envelope-to: geb-bug-gnu-emacs@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 1cwrZ3-0005bE-Um
for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Apr 2017 16:42:10 +0200
Original-Received: from localhost ([::1]:55055 helo=lists.gnu.org)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from )
id 1cwrZ4-00055J-Uv
for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Apr 2017 10:42:10 -0400
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43927)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1cwrYy-00054L-IS
for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2017 10:42:05 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from ) id 1cwrYv-0003jm-U8
for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2017 10:42:04 -0400
Original-Received: from debbugs.gnu.org ([208.118.235.43]:40032)
by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
(Exim 4.71) (envelope-from )
id 1cwrYv-0003ji-QJ
for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2017 10:42:01 -0400
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
(envelope-from ) id 1cwrYv-0002D4-KN
for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2017 10:42:01 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Philipp Stephani
Original-Sender: "Debbugs-submit"
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Sat, 08 Apr 2017 14:42:01 +0000
Resent-Message-ID:
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 26338
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords:
Original-Received: via spool by 26338-submit@debbugs.gnu.org id=B26338.14916625088467
(code B ref 26338); Sat, 08 Apr 2017 14:42:01 +0000
Original-Received: (at 26338) by debbugs.gnu.org; 8 Apr 2017 14:41:48 +0000
Original-Received: from localhost ([127.0.0.1]:38231 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from )
id 1cwrYh-0002CU-Ug
for submit@debbugs.gnu.org; Sat, 08 Apr 2017 10:41:48 -0400
Original-Received: from mail-wm0-f41.google.com ([74.125.82.41]:36591)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from ) id 1cwrYg-0002CJ-K9
for 26338@debbugs.gnu.org; Sat, 08 Apr 2017 10:41:47 -0400
Original-Received: by mail-wm0-f41.google.com with SMTP id o81so10523151wmb.1
for <26338@debbugs.gnu.org>; Sat, 08 Apr 2017 07:41:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=STWFLhf85kgvJgxUJ11w8seBKJHO0fvp+W1RYRafkio=;
b=quYP+9naSPojdSul5y1SaTXjI4xvG1jtpDQXoU76p9Q10A4LF1FthdWax8e1FKElkF
GnU4NlcADhUIW3Y5VCp/x5YHVv20o8t+ZKeMze6sIyB1BI8wDNk9psyP/qZhVvoA2h/J
j0A33lzFeu8MLiFneGUktzJ0L/dy5LzSAF/C1r1NgaicH/YkYr3spZtd9W7iPbb2II5L
DgaVOJq8A4yi083cjq5QA9WrcXptwmpjOvvh8Naaqwihhkb8oBUKKk+4fh2CrZk0UNP9
/fCmgwpqD4LZ5WSegxNc71yoiCZE30CnkPbKZ4LS4QsL7oQpGdjIr2oQxIjvwifYDWJW
cQiA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=STWFLhf85kgvJgxUJ11w8seBKJHO0fvp+W1RYRafkio=;
b=ufE2WHfYtfjEaD+I16Mwp4q/mVYTxC4jnZMFefOX/9PGhJSmXg0l8Ct3uIDaAgX2fk
mkaFV5KsLM4UlsA5G//o0XqR2AzwTNr01ehEzQwCQAFJGrF9E4eyaZ9+MKS6jOkoWEnd
JDYPr+4lRYkrs5vZME1t4RipvI+3dU/7a6RKNo79Q8sf/AIsTpldvV/1QdmajGRZ0/o8
u2bwkryFXFXVAeHYCKAb80ZaNykM3VDqoZDim58DjKr42tDg5OHJL6hs3M73bUlgkVUW
Y/V85MA/IAm9WEggaPWz2kamh3FQvcgalzmGs3y6zVaUwM/yXL+xsnX52/NLUrwjnY/v
jTEg==
X-Gm-Message-State: AN3rC/5ilmgIqxxtncYX65YrCnGNNsM0bBe3R5K/DFVE6Fz1AvvuQxJC
A5J+MYk7G5j+l6lKnZ1QMvZq1rVaeQ==
X-Received: by 10.28.73.197 with SMTP id w188mr3673043wma.46.1491662500943;
Sat, 08 Apr 2017 07:41:40 -0700 (PDT)
In-Reply-To:
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 208.118.235.43
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
the Swiss army knife of text editors"
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org
Original-Sender: "bug-gnu-emacs"
Xref: news.gmane.org gmane.emacs.bugs:131368
Archived-At:
--001a114b30ec7e5e13054ca8bd19
Content-Type: text/plain; charset=UTF-8
Tino Calancha schrieb am Sa., 8. Apr. 2017 um
15:42 Uhr:
>
>
> On Sat, 8 Apr 2017, Philipp Stephani wrote:
>
> >
> >
> > Tino Calancha schrieb am Sa., 8. Apr. 2017 um
> 06:46 Uhr:
> >
> >
> > On Fri, 7 Apr 2017, Drew Adams wrote:
> >
> > >>> Or an addition to cl-loop that would allow doing something like
> > >>>
> > >>> (cl-loop for m being the matches of "foo\\|bar"
> > >>> do ...)
> > >>>
> > >>> Then you could easily 'collect m' to get the list of matches
> if you want
> > >>> that.
> > >>
> > >> Your proposals looks nice to me ;-)
> > >
> > > (Caveat: I have not been following this thread.)
> > >
> > > I think that `cl-loop' should be as close to Common Lisp `loop'
> > > as we can reasonably make it. We should _not_ be adding other
> > > features to it or changing its behavior away from what it is
> > > supposedly emulating.
> > >
> > > If you want, create a _different_ macro that is Emacs-specific,
> > > with whatever behavior you want. Call it whatever you want
> > > that will not be confused with Common Lisp emulation.
> > >
> > > Please keep `cl-' for Common Lisp emulation. We've already
> > > seen more than enough tampering with this - people adding
> > > their favorite thing to the `cl-' namespace. Not good.
> > Drew, i respect your opinion; but so far the change
> > would just extend `cl-loop' which as you noticed has being already
> > extended before.
> > For instance, we have:
> > cl-loop for x being the overlays/buffers ...
> >
> > Don't see a problem to have those things.
> >
> >
> > I do. They couple the idea of an iterable with a looping construct, and
> such coupling is bad for various reasons:
> > - Coupling of unrelated entities is always an antipattern.
> > - For N iterables and M looping constructs, you need to implement N*M
> integrations.
> > Instead this should use an iterable, e.g. a generator function
> (iter-defun). cl-loop supports these out of the box.
> Then, you don't like (as Drew, but for different reasons) that we have:
> cl-loop for x being the buffers ...
>
I don't like it, but it's there and cannot be removed for compatibility
reasons, so I'm not arguing about it. I'm arguing against adding more such
one-off forms.
>
> but it seems you are fine having iter-by clause in cl-loop, which seems an
> Emacs extension (correctme if i am wrong). So in principle, you are happy
> with adding useful extensions to CL, not just keep it an emulation as
> Drew wants.
>
Yes, I don't care about Common Lisp. The iter-by clause is less of a
problem than 'buffers' etc. because it's not a one-off that couples a
looping construct with some random semantics.
>
> Your point is about performance.
No, I care mostly about clarity, simplicity, and good API design, including
separation of concerns.
> I am driven by easy to write code.
> Maybe you can provide an example about how to write those things using
> the iter-by cl-loop clause.
Sure:
(require 'generator)
(iter-defun re-matches (regexp)
(while (re-search-forward regexp nil t)
(iter-yield (match-string 0))))
(iter-do (m (re-matches (rx digit)))
(print m))
(cl-loop for m iter-by (re-matches (rx digit))
do (print m))
--001a114b30ec7e5e13054ca8bd19
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
>
>
> Tino Calancha <tino.calancha@gmail.com> schrieb am Sa.=
, 8. Apr. 2017 um 06:46=C2=A0Uhr:
>
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0On Fri, 7 Apr 2017, Drew Adams wrote:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>>> Or an addition to cl-loop that =
would allow doing something like
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>>>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>>>=C2=A0 =C2=A0 (cl-loop for m bei=
ng the matches of "foo\\|bar"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0do ...)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>>>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>>> Then you could easily 'coll=
ect m' to get the list of matches if you want
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>>> that.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>> Your proposals looks nice to me ;-)=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0> (Caveat: I have not been following this=
thread.)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0> I think that `cl-loop' should be as=
close to Common Lisp `loop'
>=C2=A0 =C2=A0 =C2=A0 =C2=A0> as we can reasonably make it.=C2=A0 We =
should _not_ be adding other
>=C2=A0 =C2=A0 =C2=A0 =C2=A0> features to it or changing its behavior=
away from what it is
>=C2=A0 =C2=A0 =C2=A0 =C2=A0> supposedly emulating.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0> If you want, create a _different_ macro=
that is Emacs-specific,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0> with whatever behavior you want.=C2=A0 =
Call it whatever you want
>=C2=A0 =C2=A0 =C2=A0 =C2=A0> that will not be confused with Common L=
isp emulation.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0> Please keep `cl-' for Common Lisp e=
mulation.=C2=A0 We've already
>=C2=A0 =C2=A0 =C2=A0 =C2=A0> seen more than enough tampering with th=
is - people adding
>=C2=A0 =C2=A0 =C2=A0 =C2=A0> their favorite thing to the `cl-' n=
amespace.=C2=A0 Not good.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0Drew, i respect your opinion; but so far the=
change
>=C2=A0 =C2=A0 =C2=A0 =C2=A0would just extend `cl-loop' which as you=
noticed has being already
>=C2=A0 =C2=A0 =C2=A0 =C2=A0extended before.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0For instance, we have:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0cl-loop for x being the overlays/buffers ...=
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0Don't see a problem to have those things=
.=C2=A0
>
>
> I do. They couple the idea of an iterable with a looping construct, an=
d such coupling is bad for various reasons:
> - Coupling of unrelated entities is always an antipattern.
> - For N iterables and M looping constructs, you need to implement N*M =
integrations.
> Instead this should use an iterable, e.g. a generator function (iter-d=
efun). cl-loop supports these out of the box.
Then, you don't like (as Drew, but for different reasons) that we have:=
cl-loop for x being the buffers ...
I don't like it, but it's there and cannot be remo=
ved for compatibility reasons, so I'm not arguing about it. I'm arg=
uing against adding more such one-off forms.
=C2=A0
but it seems you are fine having iter-by clause in cl-loop, which seems an<=
br class=3D"gmail_msg">
Emacs extension (correctme if i am wrong).=C2=A0 So in principle, you are h=
appy
with adding useful extensions to CL, not just keep it an emulation as
Drew wants.
Yes, I =
don't care about Common Lisp. The iter-by clause is less of a problem t=
han 'buffers' etc. because it's not a one-off that couples a lo=
oping construct with some random semantics.
=C2=A0
Your point is about performance.
No, I care=
mostly about clarity, simplicity, and good API design, including separatio=
n of concerns.
=C2=A0
=C2=A0 =
I am driven by easy to write code.
Maybe you can provide an example about how to write those things using
the iter-by cl-loop clause.