GNU bug report logs - #8711
24.0.50; binding _ to unused values with lexical-binding

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Helmut Eller <eller.helmut@HIDDEN>; merged with #26960; dated Sat, 21 May 2011 18:45:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Forcibly Merged 8711 26960. Request was from npostavs@HIDDEN to control <at> debbugs.gnu.org. Full text available.

Message received at 8711 <at> debbugs.gnu.org:


Received: (at 8711) by debbugs.gnu.org; 2 Jun 2011 17:11:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 02 13:11:11 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QSBQN-0002YX-8J
	for submit <at> debbugs.gnu.org; Thu, 02 Jun 2011 13:11:11 -0400
Received: from mail-yi0-f44.google.com ([209.85.218.44])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <lekktu@HIDDEN>) id 1QSBQL-0002YJ-LW
	for 8711 <at> debbugs.gnu.org; Thu, 02 Jun 2011 13:11:10 -0400
Received: by yic13 with SMTP id 13so444539yic.3
	for <8711 <at> debbugs.gnu.org>; Thu, 02 Jun 2011 10:11:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc:content-type:content-transfer-encoding;
	bh=FRynWYQP/t8FgY7xocWiXwLK+VwGJgxXAS7Zrue5tFY=;
	b=J1Pfv4E3vIOEH619wtqZ+PRhInnmsmDP9QH/wGquYZaot41wo91fCCxfjLQUqntQX3
	xSNuFhrPVMOT79FilvfBa/l/p2yIHvyxFOXZzDhWk+5lfSad26zHIN7p5KJPNpIrAwh5
	t6aEcExAh96g4yRy6WUNKtdJPIm7leQ6N51zo=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type:content-transfer-encoding;
	b=uAQTdAGdryAH5lApS4FZmpX4WnnMSR48eT19P0hULKABuZvnLJXHpAeHD4gXPzInXZ
	fGnrfVlbGfUZyMxkV04OTdlqnmxBCxk7dpFIQgvgQq7/WXk0JM2VnR2ZiWFJYnvluKQ1
	NSOQE0z7ol3AXvdnalGQD++H+lv+kjFVxiDkY=
Received: by 10.236.184.165 with SMTP id s25mr1263981yhm.227.1307034664091;
	Thu, 02 Jun 2011 10:11:04 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.146.82.11 with HTTP; Thu, 2 Jun 2011 10:10:24 -0700 (PDT)
In-Reply-To: <jwvr57cgwqw.fsf-monnier+emacs@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
	<jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN> <m2ipt1b2ax.fsf@HIDDEN>
	<jwvei3oj4wm.fsf-monnier+emacs@HIDDEN> <m28vtwvdpz.fsf@HIDDEN>
	<jwvfwo4gu2z.fsf-monnier+emacs@HIDDEN>
	<BANLkTi=nao0cCsha9YZjKNdNZ6kyGdUEqg@HIDDEN>
	<jwv1uzcjtlz.fsf-monnier+emacs@HIDDEN>
	<BANLkTimKoC2b=_e09s5nd5W2Ev-w8X+XxA@HIDDEN>
	<jwvr57cgwqw.fsf-monnier+emacs@HIDDEN>
From: Juanma Barranquero <lekktu@HIDDEN>
Date: Thu, 2 Jun 2011 19:10:24 +0200
Message-ID: <BANLkTikE-DYoJm8QgOkxm=nXXFW00F_Dwg@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.3 (---)
X-Debbugs-Envelope-To: 8711
Cc: 8711 <at> debbugs.gnu.org, Helmut Eller <eller.helmut@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.3 (---)

On Thu, Jun 2, 2011 at 16:00, Stefan Monnier <monnier@HIDDEN> wro=
te:

> I don't know which particular case you're referring to

The one I described earlier:

C:\emacs\trunk> bin\emacs.exe -batch -Q -f batch-byte-compile lisp\doc-view=
.el

In toplevel form:
doc-view.el:614:1:Warning: Unused lexical variable `item'
Wrote c:/emacs/trunk/lisp/doc-view.elc

where line 614 points to this function:

(defun doc-view-remove-if (predicate list)
  "Return LIST with all items removed that satisfy PREDICATE."
  (let (new-list)
    (dolist (item list (nreverse new-list))
      (when (not (funcall predicate item))
        (setq new-list (cons item new-list))))))


=C2=A0 =C2=A0 Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at 8711 <at> debbugs.gnu.org:


Received: (at 8711) by debbugs.gnu.org; 2 Jun 2011 14:00:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 02 10:00:46 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QS8S5-0006VP-R4
	for submit <at> debbugs.gnu.org; Thu, 02 Jun 2011 10:00:46 -0400
Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1QS8S3-0006VC-Tp
	for 8711 <at> debbugs.gnu.org; Thu, 02 Jun 2011 10:00:44 -0400
Received: from 121-249-126-200.fibertel.com.ar ([200.126.249.121]:18854
	helo=ceviche.home)
	by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <monnier@HIDDEN>)
	id 1QS8Ry-0000Ve-0i; Thu, 02 Jun 2011 10:00:38 -0400
Received: by ceviche.home (Postfix, from userid 20848)
	id 2D05D660DD; Thu,  2 Jun 2011 11:00:34 -0300 (ART)
From: Stefan Monnier <monnier@HIDDEN>
To: Juanma Barranquero <lekktu@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Message-ID: <jwvr57cgwqw.fsf-monnier+emacs@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
	<jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN> <m2ipt1b2ax.fsf@HIDDEN>
	<jwvei3oj4wm.fsf-monnier+emacs@HIDDEN> <m28vtwvdpz.fsf@HIDDEN>
	<jwvfwo4gu2z.fsf-monnier+emacs@HIDDEN>
	<BANLkTi=nao0cCsha9YZjKNdNZ6kyGdUEqg@HIDDEN>
	<jwv1uzcjtlz.fsf-monnier+emacs@HIDDEN>
	<BANLkTimKoC2b=_e09s5nd5W2Ev-w8X+XxA@HIDDEN>
Date: Thu, 02 Jun 2011 11:00:34 -0300
In-Reply-To: <BANLkTimKoC2b=_e09s5nd5W2Ev-w8X+XxA@HIDDEN> (Juanma
	Barranquero's message of "Thu, 2 Jun 2011 15:41:32 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -6.0 (------)
X-Debbugs-Envelope-To: 8711
Cc: 8711 <at> debbugs.gnu.org, Helmut Eller <eller.helmut@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.0 (------)

> Meanwhile, will you complain if I change that particular case (in
> doc-view.el) to be like

> (let (...)
>   (dolist (var list)
>     ...)
>   result)

> to avoid the warning?

I don't know which particular case you're referring to, but I've already
installed such changes under the banner "silence compiler warnings".
So yes, by all means,


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at 8711 <at> debbugs.gnu.org:


Received: (at 8711) by debbugs.gnu.org; 2 Jun 2011 13:42:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 02 09:42:20 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QS8AF-000622-II
	for submit <at> debbugs.gnu.org; Thu, 02 Jun 2011 09:42:19 -0400
Received: from mail-gw0-f44.google.com ([74.125.83.44])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <lekktu@HIDDEN>) id 1QS8AE-00061q-7Y
	for 8711 <at> debbugs.gnu.org; Thu, 02 Jun 2011 09:42:18 -0400
Received: by gwb20 with SMTP id 20so346420gwb.3
	for <8711 <at> debbugs.gnu.org>; Thu, 02 Jun 2011 06:42:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc:content-type:content-transfer-encoding;
	bh=FGfP16zjzJHMKZFHJXr6/vzDljTQ98Gqi1Urwm3V/Jk=;
	b=TwuNWlp6ZbSEp4CMayPyfCPjVZe89gdenDxLxr9+N9FffRZzpygPfq01rfT6dSbiQ0
	el7j+xrWiJvSZOJfYBz2dWIHpYfIuj346tSq2BM8xydSHcDKMU8bazaHz0Y+hdfl3U4l
	BRDq7vSB6q8Q8UZB0Hc+MBvcsnE7Br8QOFfYo=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type:content-transfer-encoding;
	b=ldhncYxNYO8dbEMt/7WBtUp7Vu2m+BCVHbcLMznjax1a+6Rl2gHkcXYXaOJifzM+VK
	mbPNP2tEUWGBs32q1UdbOuVed/1hbbqpibma0QnnpaauhZgCNCgv7X+2g6N8Y6N3zWNi
	8Zq5JMfOFAH2Ad8QGWPYDWhouLp3EBaTkVA7Q=
Received: by 10.150.170.2 with SMTP id s2mr778479ybe.16.1307022132299; Thu, 02
	Jun 2011 06:42:12 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.146.82.11 with HTTP; Thu, 2 Jun 2011 06:41:32 -0700 (PDT)
In-Reply-To: <jwv1uzcjtlz.fsf-monnier+emacs@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
	<jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN> <m2ipt1b2ax.fsf@HIDDEN>
	<jwvei3oj4wm.fsf-monnier+emacs@HIDDEN> <m28vtwvdpz.fsf@HIDDEN>
	<jwvfwo4gu2z.fsf-monnier+emacs@HIDDEN>
	<BANLkTi=nao0cCsha9YZjKNdNZ6kyGdUEqg@HIDDEN>
	<jwv1uzcjtlz.fsf-monnier+emacs@HIDDEN>
From: Juanma Barranquero <lekktu@HIDDEN>
Date: Thu, 2 Jun 2011 15:41:32 +0200
Message-ID: <BANLkTimKoC2b=_e09s5nd5W2Ev-w8X+XxA@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.5 (---)
X-Debbugs-Envelope-To: 8711
Cc: 8711 <at> debbugs.gnu.org, Helmut Eller <eller.helmut@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.5 (---)

On Thu, Jun 2, 2011 at 14:45, Stefan Monnier <monnier@HIDDEN> wro=
te:

> That's how dolist/dotimes are defined in Common-Lisp, hence that's
> how it works in cl-macs. =C2=A0The subr versions also do it because when =
we
> introduced them, some people brought up the issue and it seemed there
> was no point in being incompatible.

I wonder what kind of code (other than a specific test) makes this
incompatibility noticeable in the first place... but I digress ;-)

> Yes, I do find it very odd as well, but CLHS says clearly "At the time
> result-form is processed, var is bound to nil".

Silly me, I should've checked the CLHS. I would still be puzzled, but
at least not by Emacs.

> Or she can just use different names rather than reusing the same
> variable name.

Yeah, that too.

>> so setting it to nil in the (dolist (VAR LIST RESULT) ...) case does
>> not bring any clear benefit, even in the non-lexical case.
>
> Agreed.

Well, at the very least that's something that could/should be
optimized away (at some point in the future, I mean) in the
lexical-binding case (I think we already have some macros that expand
to different code for lexical and non-lexical compilations?).

Meanwhile, will you complain if I change that particular case (in
doc-view.el) to be like

(let (...)
  (dolist (var list)
    ...)
  result)

to avoid the warning?

=C2=A0 =C2=A0 Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at 8711 <at> debbugs.gnu.org:


Received: (at 8711) by debbugs.gnu.org; 2 Jun 2011 12:45:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 02 08:45:21 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QS7H7-0004oT-BJ
	for submit <at> debbugs.gnu.org; Thu, 02 Jun 2011 08:45:21 -0400
Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1QS7H5-0004oG-45
	for 8711 <at> debbugs.gnu.org; Thu, 02 Jun 2011 08:45:20 -0400
Received: from 121-249-126-200.fibertel.com.ar ([200.126.249.121]:17050
	helo=ceviche.home)
	by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <monnier@HIDDEN>)
	id 1QS7Gz-0004l8-Mc; Thu, 02 Jun 2011 08:45:13 -0400
Received: by ceviche.home (Postfix, from userid 20848)
	id D891C660DD; Thu,  2 Jun 2011 09:45:09 -0300 (ART)
From: Stefan Monnier <monnier@HIDDEN>
To: Juanma Barranquero <lekktu@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Message-ID: <jwv1uzcjtlz.fsf-monnier+emacs@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
	<jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN> <m2ipt1b2ax.fsf@HIDDEN>
	<jwvei3oj4wm.fsf-monnier+emacs@HIDDEN> <m28vtwvdpz.fsf@HIDDEN>
	<jwvfwo4gu2z.fsf-monnier+emacs@HIDDEN>
	<BANLkTi=nao0cCsha9YZjKNdNZ6kyGdUEqg@HIDDEN>
Date: Thu, 02 Jun 2011 09:45:09 -0300
In-Reply-To: <BANLkTi=nao0cCsha9YZjKNdNZ6kyGdUEqg@HIDDEN> (Juanma
	Barranquero's message of "Thu, 2 Jun 2011 13:17:56 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -6.0 (------)
X-Debbugs-Envelope-To: 8711
Cc: 8711 <at> debbugs.gnu.org, Helmut Eller <eller.helmut@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.0 (------)

> Apparently, the macroexpansion of `dolist' invokes RESULT as

> (setq VAR nil)
> RESULT

> or, in the cl-macs `dolist', as

> (let ((VAR nil))
>   RESULT)

> which I suppose has been doing for decades, but is still a bit
> strange.

That's how dolist/dotimes are defined in Common-Lisp, hence that's
how it works in cl-macs.  The subr versions also do it because when we
introduced them, some people brought up the issue and it seemed there
was no point in being incompatible.

> The docstring for `dolist' does not say that VAR is set to
> nil before computing RESULT.

Indeed.

> If computing RESULT needed the last VAR, the current code precludes it
> (unless it requires VAR to be nil, of course ;-)

Yes, I do find it very odd as well, but CLHS says clearly "At the time
result-form is processed, var is bound to nil".

> And, if computing RESULT requieres an outside VAR, the programmer is
> going to be forced to use this anyway:

> (let ((VAR 'myval))
>   (dolist (VAR mylist)
>     ...)
>   (compute-my-result VAR))  ;; with the let-bound VAR, not the dolist-bound one

Or she can just use different names rather than reusing the same
variable name.

> so setting it to nil in the (dolist (VAR LIST RESULT) ...) case does
> not bring any clear benefit, even in the non-lexical case.

Agreed.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at 8711 <at> debbugs.gnu.org:


Received: (at 8711) by debbugs.gnu.org; 2 Jun 2011 11:18:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 02 07:18:43 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QS5vH-0001zs-Ez
	for submit <at> debbugs.gnu.org; Thu, 02 Jun 2011 07:18:43 -0400
Received: from mail-yx0-f172.google.com ([209.85.213.172])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <lekktu@HIDDEN>) id 1QS5vF-0001zb-Np
	for 8711 <at> debbugs.gnu.org; Thu, 02 Jun 2011 07:18:42 -0400
Received: by yxk30 with SMTP id 30so296354yxk.3
	for <8711 <at> debbugs.gnu.org>; Thu, 02 Jun 2011 04:18:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc:content-type;
	bh=6VXGV6o9hXFw0ElsraqeaEoo/2tz0wQ131jkC1hSLd8=;
	b=FYi++23eh5M1ZEsFJLgya+OSqYFxmUbuuKdoVgX7adYFF1P75L28GcACl8cnrgDivm
	QzpcxW2Lv09LVgWH2m1qZOnCoocKvh6pCqvEUtRaLdOqdAASYLAbd/VudomUaiy5cu0t
	gJ9s9j4DtoQZJkmjRWwNuAE/578e7vsE+VX3w=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type;
	b=QiScWFbGj87yaQbBaPS6S82Hklch7jFnoKau6ZVxpaz/6GBIcPUADKdTIVVUzZHZOd
	43sY4tge+E3adUDWjNSEaRWx2xkVomzMU72yK1UbSAWk9MDKpv+Wu8RRY/2PVJ6rZxw+
	it/7rRJpU2iwTT/iHiQwinckVVoWjzmyaDk8s=
Received: by 10.236.182.103 with SMTP id n67mr719746yhm.26.1307013516117; Thu,
	02 Jun 2011 04:18:36 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.146.82.11 with HTTP; Thu, 2 Jun 2011 04:17:56 -0700 (PDT)
In-Reply-To: <jwvfwo4gu2z.fsf-monnier+emacs@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
	<jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN> <m2ipt1b2ax.fsf@HIDDEN>
	<jwvei3oj4wm.fsf-monnier+emacs@HIDDEN> <m28vtwvdpz.fsf@HIDDEN>
	<jwvfwo4gu2z.fsf-monnier+emacs@HIDDEN>
From: Juanma Barranquero <lekktu@HIDDEN>
Date: Thu, 2 Jun 2011 13:17:56 +0200
Message-ID: <BANLkTi=nao0cCsha9YZjKNdNZ6kyGdUEqg@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset=UTF-8
X-Spam-Score: -3.3 (---)
X-Debbugs-Envelope-To: 8711
Cc: 8711 <at> debbugs.gnu.org, Helmut Eller <eller.helmut@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.3 (---)

Speaking of unexpected warnings in lexical code:

  (let (new-list)
    (dolist (item list (nreverse new-list))
      (when (not (funcall predicate item))
	(setq new-list (cons item new-list)))))

In toplevel form:
doc-view.el:614:1:Warning: Unused lexical variable `item'
Wrote c:/emacs/trunk/lisp/doc-view.elc

but it does not happen if the RESULT of `dolist' is moved outside:

  (let (new-list)
    (dolist (item list)
      (when (not (funcall predicate item))
	(setq new-list (cons item new-list))))
     (nreverse new-list))

Apparently, the macroexpansion of `dolist' invokes RESULT as

(setq VAR nil)
RESULT

or, in the cl-macs `dolist', as

(let ((VAR nil))
  RESULT)

which I suppose has been doing for decades, but is still a bit
strange. The docstring for `dolist' does not say that VAR is set to
nil before computing RESULT.

If computing RESULT needed the last VAR, the current code precludes it
(unless it requires VAR to be nil, of course ;-)

And, if computing RESULT requieres an outside VAR, the programmer is
going to be forced to use this anyway:

(let ((VAR 'myval))
  (dolist (VAR mylist)
    ...)
  (compute-my-result VAR))  ;; with the let-bound VAR, not the dolist-bound one

so setting it to nil in the (dolist (VAR LIST RESULT) ...) case does
not bring any clear benefit, even in the non-lexical case.

Or am I missing something obvious?




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at 8711 <at> debbugs.gnu.org:


Received: (at 8711) by debbugs.gnu.org; 24 May 2011 12:42:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue May 24 08:42:44 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QOqwd-0002FD-Ud
	for submit <at> debbugs.gnu.org; Tue, 24 May 2011 08:42:44 -0400
Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1QOqwb-0002F0-AZ
	for 8711 <at> debbugs.gnu.org; Tue, 24 May 2011 08:42:42 -0400
Received: from 213-159-126-200.fibertel.com.ar ([200.126.159.213]:42924
	helo=ceviche.home)
	by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <monnier@HIDDEN>)
	id 1QOqwV-0002tu-RB; Tue, 24 May 2011 08:42:36 -0400
Received: by ceviche.home (Postfix, from userid 20848)
	id E77C8662FB; Tue, 24 May 2011 09:42:31 -0300 (ART)
From: Stefan Monnier <monnier@HIDDEN>
To: Helmut Eller <eller.helmut@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Message-ID: <jwvfwo4gu2z.fsf-monnier+emacs@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
	<jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN> <m2ipt1b2ax.fsf@HIDDEN>
	<jwvei3oj4wm.fsf-monnier+emacs@HIDDEN> <m28vtwvdpz.fsf@HIDDEN>
Date: Tue, 24 May 2011 09:42:31 -0300
In-Reply-To: <m28vtwvdpz.fsf@HIDDEN> (Helmut Eller's message of "Tue, 24
	May 2011 08:01:44 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -6.0 (------)
X-Debbugs-Envelope-To: 8711
Cc: 8711 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.0 (------)

> ;; -*- lexical-binding: t -*-
> (defun foo (x) (destructuring-bind (y &rest _) x y))

> x.el:2:1:Warning: variable `_' not left unused

Ah, yes, this one.  This is because CL's destructuring-bind expands the
above to something like

  (let ((_ x)
        (y (prog1 (car _) (setq _ (cdr _)))))
   y)

where _ is indeed not left unused.  It also means that a closure that
for (destructuring-bind (y &rest z) x (lambda () z)) the closure
captures a mutated var which is something more costly (the var needs to
be put inside a cons cell, leading to code along the lines of:

  (let ((z (list x))
        (y (prog1 (car (car z)) (setcar z (cdr (car z))))))
   (make-closure () [z] (car z)))

Again this is a side-effect of `let' being costly in dynbind code.
For lexbind code it would be better for destructuring-bind to use an
additional internal var:

  (let ((<internal> x)
        (y (prog1 (car <internal>) (setq <internal> (cdr <internal>))))
        (_ <internal>))
    y)

Which would not generate any warning and would lead to more efficient
code when the &rest var is captured by a closure.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 May 2011 06:02:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue May 24 02:02:40 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QOkhT-0001E3-IV
	for submit <at> debbugs.gnu.org; Tue, 24 May 2011 02:02:39 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOkhR-0001Dr-OM
	for submit <at> debbugs.gnu.org; Tue, 24 May 2011 02:02:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOkhL-0002rw-Q6
	for submit <at> debbugs.gnu.org; Tue, 24 May 2011 02:02:32 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_MED, RCVD_NUMERIC_HELO, T_RP_MATCHES_RCVD,
	T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([140.186.70.17]:50724)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOkhL-0002rs-Ol
	for submit <at> debbugs.gnu.org; Tue, 24 May 2011 02:02:31 -0400
Received: from eggs.gnu.org ([140.186.70.92]:34562)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOkhL-0003Y6-0T
	for bug-gnu-emacs@HIDDEN; Tue, 24 May 2011 02:02:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOkhK-0002rf-8h
	for bug-gnu-emacs@HIDDEN; Tue, 24 May 2011 02:02:30 -0400
Received: from lo.gmane.org ([80.91.229.12]:51527)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOkhK-0002rb-0n
	for bug-gnu-emacs@HIDDEN; Tue, 24 May 2011 02:02:30 -0400
Received: from list by lo.gmane.org with local (Exim 4.69)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOkh5-00044Q-FB
	for bug-gnu-emacs@HIDDEN; Tue, 24 May 2011 08:02:15 +0200
Received: from 212.46.168.133 ([212.46.168.133])
	by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <bug-gnu-emacs@HIDDEN>; Tue, 24 May 2011 08:02:15 +0200
Received: from eller.helmut by 212.46.168.133 with local (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <bug-gnu-emacs@HIDDEN>; Tue, 24 May 2011 08:02:15 +0200
X-Injected-Via-Gmane: http://gmane.org/
To: bug-gnu-emacs@HIDDEN
From: Helmut Eller <eller.helmut@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Date: Tue, 24 May 2011 08:01:44 +0200
Lines: 18
Message-ID: <m28vtwvdpz.fsf@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
	<jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN> <m2ipt1b2ax.fsf@HIDDEN>
	<jwvei3oj4wm.fsf-monnier+emacs@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain
X-Complaints-To: usenet@HIDDEN
X-Gmane-NNTP-Posting-Host: 212.46.168.133
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
Cancel-Lock: sha1:krK+O6jgjHCpts6pXn+asBCxtB8=
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -4.3 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -4.2 (----)

* Stefan Monnier [2011-05-24 00:56] writes:

>>> It can insert (ignore nil) instead which should have the same effect but
>>> without triggering the other warning with lexical-binding.
>
>> Indeed.  But I quickly run into another case where that doesn't help:
>
>> (defun foo (x) (destructuring-bind (y &rest _) x y))
>
> I don't see any warning for this code.  What warning do you get?

;; -*- lexical-binding: t -*-
(defun foo (x) (destructuring-bind (y &rest _) x y))

x.el:2:1:Warning: variable `_' not left unused


Helmut





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at 8711 <at> debbugs.gnu.org:


Received: (at 8711) by debbugs.gnu.org; 24 May 2011 00:56:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 23 20:56:53 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QOfvZ-0001Q3-Aj
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 20:56:53 -0400
Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1QOfvX-0001Ps-NO
	for 8711 <at> debbugs.gnu.org; Mon, 23 May 2011 20:56:52 -0400
Received: from 213-159-126-200.fibertel.com.ar ([200.126.159.213]:45003
	helo=ceviche.home)
	by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <monnier@HIDDEN>)
	id 1QOfvS-0004kd-1a; Mon, 23 May 2011 20:56:46 -0400
Received: by ceviche.home (Postfix, from userid 20848)
	id DB015662FB; Mon, 23 May 2011 21:56:43 -0300 (ART)
From: Stefan Monnier <monnier@HIDDEN>
To: Helmut Eller <eller.helmut@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Message-ID: <jwvei3oj4wm.fsf-monnier+emacs@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
	<jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN> <m2ipt1b2ax.fsf@HIDDEN>
Date: Mon, 23 May 2011 21:56:43 -0300
In-Reply-To: <m2ipt1b2ax.fsf@HIDDEN> (Helmut Eller's message of "Mon, 23
	May 2011 22:16:22 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -6.0 (------)
X-Debbugs-Envelope-To: 8711
Cc: 8711 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.0 (------)

>> It can insert (ignore nil) instead which should have the same effect but
>> without triggering the other warning with lexical-binding.

> Indeed.  But I quickly run into another case where that doesn't help:

> (defun foo (x) (destructuring-bind (y &rest _) x y))

I don't see any warning for this code.  What warning do you get?

> The semantic of loop (in Common Lisp) allows both variants. So the
> "portable" idiom is "collect (let ((value value)) (lambda () value))".

Interesting.  I didn't think they'd accept the alternate semantic, which
is clearly less useful and less efficient at the same time (tho maybe
there are implementation strategies that may not make it that much less
efficient).


        Stefan






Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at 8711 <at> debbugs.gnu.org:


Received: (at 8711) by debbugs.gnu.org; 24 May 2011 00:52:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 23 20:52:11 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QOfr1-0001Jn-0V
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 20:52:11 -0400
Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1QOfqy-0001Jb-Pj
	for 8711 <at> debbugs.gnu.org; Mon, 23 May 2011 20:52:09 -0400
Received: from 213-159-126-200.fibertel.com.ar ([200.126.159.213]:51590
	helo=ceviche.home)
	by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <monnier@HIDDEN>)
	id 1QOfqt-0004YS-5W; Mon, 23 May 2011 20:52:03 -0400
Received: by ceviche.home (Postfix, from userid 20848)
	id 95FB5662FB; Mon, 23 May 2011 21:51:59 -0300 (ART)
From: Stefan Monnier <monnier@HIDDEN>
To: Helmut Eller <eller.helmut@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Message-ID: <jwvk4dhhqu6.fsf-monnier+emacs@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
	<jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN> <m28vtxb1jb.fsf@HIDDEN>
Date: Mon, 23 May 2011 21:51:59 -0300
In-Reply-To: <m28vtxb1jb.fsf@HIDDEN> (Helmut Eller's message of "Mon, 23
	May 2011 22:32:56 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -6.0 (------)
X-Debbugs-Envelope-To: 8711
Cc: 8711 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.0 (------)

>> I think the same problem happens with dotimes/dolist using the old
>> definition: the loop vars `key' and `value' are let-bound outside the
>> loop and then setq'd at each loop iteration (it's this setq that causes
>> them to be "not left unused").  This was OK for the dynamic scoping case
>> because let-binding is significantly more costly than setq, but it is
>> not right for the lexical scoping case where the cost of let is not
>> higher than `setq' and where the semantic is actually then wrong:
>> e.g. if you "collect (lambda () value)" the current code ends up
>> returning a list of functions that all return the last `value', rather
>> than a list of functions that each return one of the `values' in
>> the alist.
> BTW, is there a good reason why we can't disallow setq on closed over
> variables in Elisp?

Yes and no: technically, we could, of course, but I'm not sure that's
worth the trouble.  I'm in favor of pure languages (e.g. I've local
changes that make Emacs strings immutable, often install changes that
reduce the use of setq, ...) but realistically Emacs Lisp won't get rid
of setq any time soon.  Now, why single out setq on closed over variables?
Note that currently closures are used internally a lot more often than
you'd think, since every condition-case, unwind-protect, and catch
makes its body and branches into closures.  Also it's common for
lambda arguments to mapcar and mapc to use setq on some closed over
variable used a sort of accumulator.

> That kind of mutability seems like a bad idea in a
> concurrent world.

Emacs has a crapload of global state, so we won't be able to wiggle
around global mutability problems.  Maybe every bit helps, but I'm very
much unconvinced.

> Closures are a new feature so we could make a conscious decision not
> to introduce the problematic mutable variables.

But I also want it to be as easy as possible to turn valid dynbind Elisp
code into valid lexbind code, so any additional restriction needs a very
good justification.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 23 May 2011 20:33:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 23 16:33:27 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QOboc-000331-VO
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 16:33:27 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOboa-00032n-J0
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 16:33:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOboU-0000c0-Ln
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 16:33:19 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_MED, RCVD_NUMERIC_HELO, T_RP_MATCHES_RCVD,
	T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([140.186.70.17]:44054)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOboU-0000bu-Jw
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 16:33:18 -0400
Received: from eggs.gnu.org ([140.186.70.92]:55615)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOboT-0002s6-MG
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 16:33:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOboS-0000bi-OO
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 16:33:17 -0400
Received: from lo.gmane.org ([80.91.229.12]:36886)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOboS-0000bc-HW
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 16:33:16 -0400
Received: from list by lo.gmane.org with local (Exim 4.69)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOboQ-00086u-Vf
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 22:33:14 +0200
Received: from 212.46.168.133 ([212.46.168.133])
	by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <bug-gnu-emacs@HIDDEN>; Mon, 23 May 2011 22:33:14 +0200
Received: from eller.helmut by 212.46.168.133 with local (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <bug-gnu-emacs@HIDDEN>; Mon, 23 May 2011 22:33:14 +0200
X-Injected-Via-Gmane: http://gmane.org/
To: bug-gnu-emacs@HIDDEN
From: Helmut Eller <eller.helmut@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Date: Mon, 23 May 2011 22:32:56 +0200
Lines: 20
Message-ID: <m28vtxb1jb.fsf@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
	<jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain
X-Complaints-To: usenet@HIDDEN
X-Gmane-NNTP-Posting-Host: 212.46.168.133
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
Cancel-Lock: sha1:J3UnIommYjAn2nlBl165CJ1SeCE=
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -4.3 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -4.3 (----)

* Stefan Monnier [2011-05-23 19:29] writes:

> I think the same problem happens with dotimes/dolist using the old
> definition: the loop vars `key' and `value' are let-bound outside the
> loop and then setq'd at each loop iteration (it's this setq that causes
> them to be "not left unused").  This was OK for the dynamic scoping case
> because let-binding is significantly more costly than setq, but it is
> not right for the lexical scoping case where the cost of let is not
> higher than `setq' and where the semantic is actually then wrong:
> e.g. if you "collect (lambda () value)" the current code ends up
> returning a list of functions that all return the last `value', rather
> than a list of functions that each return one of the `values' in
> the alist.

BTW, is there a good reason why we can't disallow setq on closed over
variables in Elisp?  That kind of mutability seems like a bad idea in a
concurrent world.  Closures are a new feature so we could make a
conscious decision not to introduce the problematic mutable variables.

Helmut 





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 23 May 2011 20:16:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 23 16:16:55 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QObYd-0002h3-1r
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 16:16:55 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QObYb-0002gr-1G
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 16:16:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QObYS-0006OZ-0A
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 16:16:47 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_MED, RCVD_NUMERIC_HELO, T_RP_MATCHES_RCVD,
	T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([140.186.70.17]:34438)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QObYR-0006OV-V8
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 16:16:43 -0400
Received: from eggs.gnu.org ([140.186.70.92]:50525)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QObYR-0003Yl-1e
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 16:16:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QObYP-0006OB-Vl
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 16:16:43 -0400
Received: from lo.gmane.org ([80.91.229.12]:54215)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QObYP-0006Nz-GO
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 16:16:41 -0400
Received: from list by lo.gmane.org with local (Exim 4.69)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QObYK-00067q-Og
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 22:16:36 +0200
Received: from 212.46.168.133 ([212.46.168.133])
	by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <bug-gnu-emacs@HIDDEN>; Mon, 23 May 2011 22:16:36 +0200
Received: from eller.helmut by 212.46.168.133 with local (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <bug-gnu-emacs@HIDDEN>; Mon, 23 May 2011 22:16:36 +0200
X-Injected-Via-Gmane: http://gmane.org/
To: bug-gnu-emacs@HIDDEN
From: Helmut Eller <eller.helmut@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Date: Mon, 23 May 2011 22:16:22 +0200
Lines: 48
Message-ID: <m2ipt1b2ax.fsf@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
	<jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain
X-Complaints-To: usenet@HIDDEN
X-Gmane-NNTP-Posting-Host: 212.46.168.133
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
Cancel-Lock: sha1:NwQ1CWdzIKItV8IcHh7zwLoZ6uI=
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -4.3 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -4.3 (----)

* Stefan Monnier [2011-05-23 19:29] writes:

>> My problem is basically that I have a macro "destructure-case" that
>> expands to destructuring-bind, e.g.:
>
>> (destructure-case location
>>   ((:error _) nil)) ; do nothing
>
>> expands to
>
>> (ecase (car location)
>>   (:error (destructuring-bind (_) (cdr location)
>>             (ignore _)
>>             nil)))
>
>> The macro inserts the (ignore _) to suppress the "value returned from
>> (car --cl-rest--) is unused" warning.
>
> It can insert (ignore nil) instead which should have the same effect but
> without triggering the other warning with lexical-binding.

Indeed.  But I quickly run into another case where that doesn't help:

(defun foo (x) (destructuring-bind (y &rest _) x y))

>> There is also a somewhat related problem with loop:
>
>> ;; -*- lexical-binding: t -*-
>> (defun foo (alist) (loop for (_key . value) in alist collect value))
>
>> produces a "variable `_key' not left unused" warning.
>
> I think the same problem happens with dotimes/dolist using the old
> definition: the loop vars `key' and `value' are let-bound outside the
> loop and then setq'd at each loop iteration (it's this setq that causes
> them to be "not left unused").  This was OK for the dynamic scoping case
> because let-binding is significantly more costly than setq, but it is
> not right for the lexical scoping case where the cost of let is not
> higher than `setq' and where the semantic is actually then wrong:
> e.g. if you "collect (lambda () value)" the current code ends up
> returning a list of functions that all return the last `value', rather
> than a list of functions that each return one of the `values' in
> the alist.

The semantic of loop (in Common Lisp) allows both variants. So the
"portable" idiom is "collect (let ((value value)) (lambda () value))".

Helmut





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at 8711 <at> debbugs.gnu.org:


Received: (at 8711) by debbugs.gnu.org; 23 May 2011 19:29:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 23 15:29:12 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QOaoR-0001bV-Ve
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 15:29:12 -0400
Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1QOaoQ-0001bK-Bc
	for 8711 <at> debbugs.gnu.org; Mon, 23 May 2011 15:29:11 -0400
Received: from 213-159-126-200.fibertel.com.ar ([200.126.159.213]:59283
	helo=ceviche.home)
	by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <monnier@HIDDEN>)
	id 1QOaoK-0000Ht-K4; Mon, 23 May 2011 15:29:04 -0400
Received: by ceviche.home (Postfix, from userid 20848)
	id 253E266131; Mon, 23 May 2011 16:29:01 -0300 (ART)
From: Stefan Monnier <monnier@HIDDEN>
To: Helmut Eller <eller.helmut@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Message-ID: <jwvvcx1i5w6.fsf-monnier+emacs@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN> <m2tyclb7if.fsf@HIDDEN>
Date: Mon, 23 May 2011 16:29:01 -0300
In-Reply-To: <m2tyclb7if.fsf@HIDDEN> (Helmut Eller's message of "Mon, 23
	May 2011 20:23:52 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -6.0 (------)
X-Debbugs-Envelope-To: 8711
Cc: 8711 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.0 (------)

> My problem is basically that I have a macro "destructure-case" that
> expands to destructuring-bind, e.g.:

> (destructure-case location
>   ((:error _) nil)) ; do nothing

> expands to

> (ecase (car location)
>   (:error (destructuring-bind (_) (cdr location)
>             (ignore _)
>             nil)))

> The macro inserts the (ignore _) to suppress the "value returned from
> (car --cl-rest--) is unused" warning.

It can insert (ignore nil) instead which should have the same effect but
without triggering the other warning with lexical-binding.

> I think that rewriting (let ((_ foo))) to (progn foo nil) is not quite
> right because that loses the information that the value that flows to
> the variable _ is intentionally ignored, but I guess that is somewhat
> hard to fix this.  (Maybe byte-optimize-letX could call
> byte-optimize-form-code-walker directly but instead of specifying that
> the form is evaluated "for-effect" somehow say that the value is
> "ignorable".)

I'm not completely satisfied with the "value returned from <foo> is
unused" indeed, but it's not clear exactly how to fix it (short of
always silencing it, which I'd rather not since it occasionally catches
errors).

> It's perhaps easier to teach destructuring-bind the _ convention so that
> it can produce more direct code.

Could be.  destructuring-bind generates some other minorly-problematic
code for the lexbind case.

> There is also a somewhat related problem with loop:

> ;; -*- lexical-binding: t -*-
> (defun foo (alist) (loop for (_key . value) in alist collect value))

> produces a "variable `_key' not left unused" warning.

I think the same problem happens with dotimes/dolist using the old
definition: the loop vars `key' and `value' are let-bound outside the
loop and then setq'd at each loop iteration (it's this setq that causes
them to be "not left unused").  This was OK for the dynamic scoping case
because let-binding is significantly more costly than setq, but it is
not right for the lexical scoping case where the cost of let is not
higher than `setq' and where the semantic is actually then wrong:
e.g. if you "collect (lambda () value)" the current code ends up
returning a list of functions that all return the last `value', rather
than a list of functions that each return one of the `values' in
the alist.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 23 May 2011 18:24:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 23 14:24:21 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QOZnh-00006A-Ap
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 14:24:21 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOZnb-00005u-W5
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 14:24:20 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOZnV-0002Zx-PS
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 14:24:10 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_MED, RCVD_NUMERIC_HELO, T_RP_MATCHES_RCVD,
	T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([140.186.70.17]:58333)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOZnV-0002Zt-Mt
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 14:24:09 -0400
Received: from eggs.gnu.org ([140.186.70.92]:32870)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOZnU-0005nq-EL
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 14:24:09 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOZnT-0002YB-Ai
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 14:24:08 -0400
Received: from lo.gmane.org ([80.91.229.12]:44717)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOZnT-0002Xp-0v
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 14:24:07 -0400
Received: from list by lo.gmane.org with local (Exim 4.69)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOZnR-0002dc-Qc
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 20:24:05 +0200
Received: from 212.46.168.133 ([212.46.168.133])
	by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <bug-gnu-emacs@HIDDEN>; Mon, 23 May 2011 20:24:05 +0200
Received: from eller.helmut by 212.46.168.133 with local (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <bug-gnu-emacs@HIDDEN>; Mon, 23 May 2011 20:24:05 +0200
X-Injected-Via-Gmane: http://gmane.org/
To: bug-gnu-emacs@HIDDEN
From: Helmut Eller <eller.helmut@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Date: Mon, 23 May 2011 20:23:52 +0200
Lines: 53
Message-ID: <m2tyclb7if.fsf@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
	<jwvy61xldmy.fsf-monnier+emacs@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain
X-Complaints-To: usenet@HIDDEN
X-Gmane-NNTP-Posting-Host: 212.46.168.133
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
Cancel-Lock: sha1:x7wYDlHDP5iMsULobL4WrgGa+5Y=
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -4.3 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -4.3 (----)

* Stefan Monnier [2011-05-23 14:24] writes:

> The two warnings come from different analyzes:
> - The warning for `bar' comes from cconv.el which is intended to check
>   whether the variable is syntactically used, rather than semantically.
> - The warning for `foo' checks whether pure functions are not called for
>   their side-effects and it's applied after optimizations so in the
>   above code, the code generated by destructuring-bind ends up optimized
>   to something that calls `car' without binding the result to _ because
>   it figured that _ is not used and just got rid of it without warning.
>
> So most likely the answers I give here aren't satisfactory to the OP,
> since his real problem is probably different than (destructuring-bind
> (_) x) and the solution for that problem is probably going to be
> yet different.

My problem is basically that I have a macro "destructure-case" that
expands to destructuring-bind, e.g.:

(destructure-case location
  ((:error _) nil)) ; do nothing

expands to

(ecase (car location)
  (:error (destructuring-bind (_) (cdr location)
            (ignore _)
            nil)))

The macro inserts the (ignore _) to suppress the "value returned from
(car --cl-rest--) is unused" warning.  But that trick only works for the
non-lexical-binding case.

I think that rewriting (let ((_ foo))) to (progn foo nil) is not quite
right because that loses the information that the value that flows to
the variable _ is intentionally ignored, but I guess that is somewhat
hard to fix this.  (Maybe byte-optimize-letX could call
byte-optimize-form-code-walker directly but instead of specifying that
the form is evaluated "for-effect" somehow say that the value is
"ignorable".)

It's perhaps easier to teach destructuring-bind the _ convention so that
it can produce more direct code.


There is also a somewhat related problem with loop:

;; -*- lexical-binding: t -*-
(defun foo (alist) (loop for (_key . value) in alist collect value))

produces a "variable `_key' not left unused" warning.

Helmut





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at 8711 <at> debbugs.gnu.org:


Received: (at 8711) by debbugs.gnu.org; 23 May 2011 14:24:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 23 10:24:41 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QOW3l-0002eh-A3
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 10:24:41 -0400
Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1QOW3j-0002eV-AT
	for 8711 <at> debbugs.gnu.org; Mon, 23 May 2011 10:24:40 -0400
Received: from 213-159-126-200.fibertel.com.ar ([200.126.159.213]:40770
	helo=ceviche.home)
	by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <monnier@HIDDEN>)
	id 1QOW3d-00055m-Qs; Mon, 23 May 2011 10:24:34 -0400
Received: by ceviche.home (Postfix, from userid 20848)
	id 2F3FB66131; Mon, 23 May 2011 11:24:31 -0300 (ART)
From: Stefan Monnier <monnier@HIDDEN>
To: 8711 <at> debbugs.gnu.org
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Message-ID: <jwvy61xldmy.fsf-monnier+emacs@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN> <m3zkmdn63z.fsf@HIDDEN>
Date: Mon, 23 May 2011 11:24:31 -0300
In-Reply-To: <m3zkmdn63z.fsf@HIDDEN> (Lawrence Mitchell's
	message of "Mon, 23 May 2011 10:01:04 +0100")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -6.0 (------)
X-Debbugs-Envelope-To: 8711
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.0 (------)

>> There seems be no way to avoid a warning in code like this:

>> ;; -*- lexical-binding: t -*-
>> (eval-when-compile (require 'cl))
>> (defun foo (x) (destructuring-bind (_) x))

Hmm... the byte-compiler complains because the above gets turned into

     (let* ((--cl-rest-- x)
            (_
             (if (= (length --cl-rest--) 1)
                 (car --cl-rest--)
               (signal 'wrong-number-of-arguments (list nil (length --cl-rest--))))))
       nil)

which gets changes by byte-opt.el into
       
     (let* ((--cl-rest-- x))
       (if (= (length --cl-rest--) 1)
           (car --cl-rest--)
         (signal 'wrong-number-of-arguments (list nil (length --cl-rest--))))
       nil)

And note that this is only done for a `nil' body (tho it can also be
something like (progn nil) because that would be optimized to nil as
well), and not for a body like `5' (although the optimization is just
as valid for `5' as for nil).
         
>> (defun bar (x) (destructuring-bind (_) x (ignore _)))

  (defun bar (x) (destructuring-bind (_) x (ignore nil)))

works (because (ignore nil) happens not to be optimized to nil).
 
> This latter is because cconv-analyse-use is not smart enough when
> checking for use of variables starting with an underscore.

> ;; -*- lexical-binding: t -*-

> (let ((_ nil))
>   (ignore _))

> =>

> Warning: variable `_' not left unused.

> This despite ignore not touching it.

The two warnings come from different analyzes:
- The warning for `bar' comes from cconv.el which is intended to check
  whether the variable is syntactically used, rather than semantically.
- The warning for `foo' checks whether pure functions are not called for
  their side-effects and it's applied after optimizations so in the
  above code, the code generated by destructuring-bind ends up optimized
  to something that calls `car' without binding the result to _ because
  it figured that _ is not used and just got rid of it without warning.

So most likely the answers I give here aren't satisfactory to the OP,
since his real problem is probably different than (destructuring-bind
(_) x) and the solution for that problem is probably going to be
yet different.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 23 May 2011 09:01:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 23 05:01:41 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QOR1B-0002jY-7V
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 05:01:41 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOR12-0002jJ-2q
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 05:01:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOR0w-0000sP-1Y
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 05:01:26 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_MED,T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL
	autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([140.186.70.17]:57835)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOR0v-0000sL-Vy
	for submit <at> debbugs.gnu.org; Mon, 23 May 2011 05:01:25 -0400
Received: from eggs.gnu.org ([140.186.70.92]:59688)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOR0v-0002Gx-4n
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 05:01:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOR0p-0000rS-Gf
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 05:01:25 -0400
Received: from lo.gmane.org ([80.91.229.12]:44856)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOR0p-0000qq-Ap
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 05:01:19 -0400
Received: from list by lo.gmane.org with local (Exim 4.69)
	(envelope-from <geb-bug-gnu-emacs@HIDDEN>) id 1QOR0m-00032N-6n
	for bug-gnu-emacs@HIDDEN; Mon, 23 May 2011 11:01:16 +0200
Received: from e4300lm.epcc.ed.ac.uk ([129.215.63.156])
	by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <bug-gnu-emacs@HIDDEN>; Mon, 23 May 2011 11:01:16 +0200
Received: from wence by e4300lm.epcc.ed.ac.uk with local (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <bug-gnu-emacs@HIDDEN>; Mon, 23 May 2011 11:01:16 +0200
X-Injected-Via-Gmane: http://gmane.org/
To: bug-gnu-emacs@HIDDEN
From: Lawrence Mitchell <wence@HIDDEN>
Subject: Re: bug#8711: 24.0.50; binding _ to unused values with lexical-binding
Date: Mon, 23 May 2011 10:01:04 +0100
Lines: 28
Message-ID: <m3zkmdn63z.fsf@HIDDEN>
References: <m2lixzj3lp.fsf@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain
X-Complaints-To: usenet@HIDDEN
X-Gmane-NNTP-Posting-Host: e4300lm.epcc.ed.ac.uk
User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux)
Cancel-Lock: sha1:sf/qKSmsg/OtFZ/UxbhlMWi2GXM=
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -5.4 (-----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.4 (-----)

Helmut Eller wrote:
> There seems be no way to avoid a warning in code like this:

> ;; -*- lexical-binding: t -*-
> (eval-when-compile (require 'cl))
> (defun foo (x) (destructuring-bind (_) x))
> (defun bar (x) (destructuring-bind (_) x (ignore _)))

> In foo the compiler complains because _ is never used and
> it bar it complains because it is used.

This latter is because cconv-analyse-use is not smart enough when
checking for use of variables starting with an underscore.

;; -*- lexical-binding: t -*-

(let ((_ nil))
  (ignore _))

=>

Warning: variable `_' not left unused.

This despite ignore not touching it.

Lawrence
-- 
Lawrence Mitchell <wence@HIDDEN>





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 21 May 2011 18:44:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 21 14:44:38 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QNrAD-0007GC-Ud
	for submit <at> debbugs.gnu.org; Sat, 21 May 2011 14:44:38 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <eller.helmut@HIDDEN>) id 1QNrAB-0007G0-GG
	for submit <at> debbugs.gnu.org; Sat, 21 May 2011 14:44:36 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eller.helmut@HIDDEN>) id 1QNrA5-0000c1-KX
	for submit <at> debbugs.gnu.org; Sat, 21 May 2011 14:44:30 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_LOW, RFC_ABUSE_POST, T_DKIM_INVALID,
	T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([140.186.70.17]:48350)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eller.helmut@HIDDEN>) id 1QNrA5-0000bx-Iv
	for submit <at> debbugs.gnu.org; Sat, 21 May 2011 14:44:29 -0400
Received: from eggs.gnu.org ([140.186.70.92]:51264)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eller.helmut@HIDDEN>) id 1QNrA4-0001x2-Sk
	for bug-gnu-emacs@HIDDEN; Sat, 21 May 2011 14:44:29 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eller.helmut@HIDDEN>) id 1QNrA3-0000bd-V7
	for bug-gnu-emacs@HIDDEN; Sat, 21 May 2011 14:44:28 -0400
Received: from mail-ww0-f49.google.com ([74.125.82.49]:44199)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eller.helmut@HIDDEN>) id 1QNrA3-0000bO-Po
	for bug-gnu-emacs@HIDDEN; Sat, 21 May 2011 14:44:27 -0400
Received: by wwb39 with SMTP id 39so4150372wwb.30
	for <bug-gnu-emacs@HIDDEN>; Sat, 21 May 2011 11:44:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:subject:date:message-id:user-agent
	:mime-version:content-type;
	bh=ObjyGyd88LNR0+WfdpdxZkF+BG4gAuHlCbAogeStNCs=;
	b=m1CnKhaPucaZ05JI89ctxNI2hqC/XrITE4v78hOLGEsZVEIK8qsLSitCtp31rVgqUZ
	zCHk1dWaVlIy1RIIMBbAS6tKxSepqWbz4Fm/FAqiKgIr4IAvo/BG1T/285y24LlwF1eY
	hNtmm0NVf8PSHhFxlFZH1PwO7dCE6qwrcd+cc=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:subject:date:message-id:user-agent:mime-version
	:content-type;
	b=hkij+hiI3UlS4ixtvNzbS9jxcFyUPXEVLsGQEEK6c0AcdKIi6BbWq/MfvIyY1RG+cY
	2pdF7s/MKP+swogeVJT3T2cWQ6vCJ3EwC+TI8ggE4NxDzYi3dm7hlKs1iOg09osn2Fl+
	e1vWvCUNoQrGjju8qZPybzRMLp6piPiMptOg8=
Received: by 10.216.191.208 with SMTP id g58mr715457wen.85.1306003466676;
	Sat, 21 May 2011 11:44:26 -0700 (PDT)
Received: from ix ([212.46.168.133])
	by mx.google.com with ESMTPS id s40sm2436810weq.4.2011.05.21.11.44.24
	(version=TLSv1/SSLv3 cipher=OTHER);
	Sat, 21 May 2011 11:44:25 -0700 (PDT)
Received: from helmut by ix with local (Exim 4.72)
	(envelope-from <eller.helmut@HIDDEN>) id 1QNr9u-0007cV-Ej
	for bug-gnu-emacs@HIDDEN; Sat, 21 May 2011 20:44:18 +0200
From: Helmut Eller <eller.helmut@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 24.0.50; binding _ to unused values with lexical-binding
Date: Sat, 21 May 2011 20:44:18 +0200
Message-ID: <m2lixzj3lp.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -5.3 (-----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.3 (-----)

There seems be no way to avoid a warning in code like this:

;; -*- lexical-binding: t -*-
(eval-when-compile (require 'cl))
(defun foo (x) (destructuring-bind (_) x))
(defun bar (x) (destructuring-bind (_) x (ignore _)))

In foo the compiler complains because _ is never used and
it bar it complains because it is used.


In GNU Emacs 24.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2011-05-21 on ix
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
configured using `configure  '--with-gif=no' '--with-gnutls=no''




Acknowledgement sent to Helmut Eller <eller.helmut@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8711; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.