From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.bugs Subject: bug#20268: 25.0.50; pcase-lambda broken Date: Wed, 08 Apr 2015 15:08:36 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b3a8b34c8105b051337e7f4 X-Trace: ger.gmane.org 1428505776 28845 80.91.229.3 (8 Apr 2015 15:09:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Apr 2015 15:09:36 +0000 (UTC) Cc: 20268@debbugs.gnu.org To: Stefan Monnier , Leo Liu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 08 17:09:27 2015 Return-path: Envelope-to: geb-bug-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 1YfrbX-000738-Q0 for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Apr 2015 17:09:24 +0200 Original-Received: from localhost ([::1]:53320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YfrbX-0000na-4b for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Apr 2015 11:09:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YfrbG-0000Wa-L1 for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2015 11:09:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YfrbC-0003XI-Gj for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2015 11:09:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YfrbC-0003XE-Ds for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2015 11:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YfrbC-00039J-5H for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2015 11:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Stephani Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Apr 2015 15:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20268 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20268-submit@debbugs.gnu.org id=B20268.142850572812086 (code B ref 20268); Wed, 08 Apr 2015 15:09:02 +0000 Original-Received: (at 20268) by debbugs.gnu.org; 8 Apr 2015 15:08:48 +0000 Original-Received: from localhost ([127.0.0.1]:49309 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yfray-00038s-0T for submit@debbugs.gnu.org; Wed, 08 Apr 2015 11:08:48 -0400 Original-Received: from mail-wi0-f179.google.com ([209.85.212.179]:33551) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yfrar-00038a-SU for 20268@debbugs.gnu.org; Wed, 08 Apr 2015 11:08:46 -0400 Original-Received: by wiax7 with SMTP id x7so35299351wia.0 for <20268@debbugs.gnu.org>; Wed, 08 Apr 2015 08:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=947KW7qPNmlhUkOnUGIRXg7jV2pVuQsYu8yG01v1ve0=; b=VBhIrLpC7rDWZAlv7cdej2jLc7YRwE3LiZjKcZ1pB00Na6vRozQDDt2LSIewO96qMW d+nzEU89UIxfDgkQGNKnDjimNgMEBh0QC9JezHYl9toJqaqqzKifYC9rM6Gs2rHTyxDj 2DwrPHIiyVl68CpwD0qZNiWhXmQ9VEnRGaz3V5D4Vz800j0DcO114zr5DdqhLN6t5Kpg qc2UMaeE5GwNaiZZ29xJWivopjYhZtr/50hpP4ENof0NHLkIxJfv5lszkyNOqLfuk/Fb z8XkAZnfOL5dwI9GYwOwC23vLNGVaqknWN8ETNhnTYSWEfOzaXcbKtoZrHmq9NQteaUJ lELQ== X-Received: by 10.194.19.166 with SMTP id g6mr51725882wje.150.1428505716328; Wed, 08 Apr 2015 08:08:36 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:101290 Archived-At: --047d7b3a8b34c8105b051337e7f4 Content-Type: text/plain; charset=UTF-8 Stefan Monnier schrieb am Mi., 8. Apr. 2015 um 04:15 Uhr: > > After the recent rewrite, pcase-lambda is broken. For example, eval the > > following to get 46422 instead of the correct value 65535. > > > (cl-some (pcase-lambda (`[fullsweep_after ,v]) v) > > '([min_bin_vheap_size 46422] > > [min_heap_size 233] > > [fullsweep_after 65535] > > [minor_gcs 40])) > > Indeed, that's the semantics I chose. > The previous semantics was for the function to do nothing and return nil > if the arg doesn't match. The new semantics is the same as the one used > by pcase-let. It's not without its fault of course, but at least it does > correspond to the usual idea of "destructuring" and generates more > efficient code. > > I think if you prefer to return nil, then the macro should look like > > (pcase-lambda ((`[fullsweep_after ,v]) v)) > > which would then naturally let you add additional cases like > > (pcase-lambda ((`[fullsweep_after ,v]) v) > ((`[min_heap_size ,v]) (/ v 2))) > > Admittedly, for the current pcase-lambda (and pcase-let) macro, the > pcase.el code should be refined so as to emit a warning when it ends up > ignoring a constant like `fullsweep_after' above. > > Why not raise an error instead if there is no match (or even if any quoted or self-quoting expressions are used at all)? The current behavior is quite confusing, and warnings tend to be ignored. Given that pcase-let, pcase-lambda and pcase-dolist don't do any case-by-case analysis, maybe they should even be renamed and moved out of pcase.el. --047d7b3a8b34c8105b051337e7f4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Stefan Monnier <monnier@iro.umontreal.ca> sc= hrieb am Mi., 8. Apr. 2015 um 04:15=C2=A0Uhr:
> After the recent rewrite, pcase-lambda is broken. For example, ev= al the
> following to get 46422 instead of the correct value 65535.

>=C2=A0 =C2=A0 (cl-some (pcase-lambda (`[fullsweep_after ,v]) v)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'([min_bin_vheap_si= ze 46422]
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[min_heap_size 2= 33]
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[fullsweep_after= 65535]
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[minor_gcs 40]))=

Indeed, that's the semantics I chose.
The previous semantics was for the function to do nothing and return nil if the arg doesn't match.=C2=A0 The new semantics is the same as the on= e used
by pcase-let.=C2=A0 It's not without its fault of course, but at least = it does
correspond to the usual idea of "destructuring" and generates mor= e
efficient code.

I think if you prefer to return nil, then the macro should look like

=C2=A0 =C2=A0(pcase-lambda ((`[fullsweep_after ,v]) v))

which would then naturally let you add additional cases like

=C2=A0 =C2=A0(pcase-lambda ((`[fullsweep_after ,v]) v)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((`[min_heap_= size ,v]) (/ v 2)))

Admittedly, for the current pcase-lambda (and pcase-let) macro, the
pcase.el code should be refined so as to emit a warning when it ends up
ignoring a constant like `fullsweep_after' above.


Why not raise an error instead if there is= no match (or even if any quoted or self-quoting expressions are used at al= l)? The current behavior is quite confusing, and warnings tend to be ignore= d.=C2=A0

Given that pcase-let, pcase-lambda and pc= ase-dolist don't do any case-by-case analysis, maybe they should even b= e renamed and moved out of pcase.el.
--047d7b3a8b34c8105b051337e7f4--