GNU bug report logs - #25017
Fwd: Re: dotimes var comiler warning

Previous Next

Package: emacs;

Reported by: Andreas Röhler <andreas.roehler <at> easy-emacs.de>

Date: Thu, 24 Nov 2016 14:02:02 UTC

Severity: wishlist

Done: Michael Heerdegen <michael_heerdegen <at> web.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25017 in the body.
You can then email your comments to 25017 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#25017; Package emacs. (Thu, 24 Nov 2016 14:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andreas Röhler <andreas.roehler <at> easy-emacs.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 24 Nov 2016 14:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Fwd: Re: dotimes var comiler warning
Date: Thu, 24 Nov 2016 15:10:02 +0100
[Message part 1 (text/plain, inline)]
See text below, thanks!


-------- Forwarded Message --------
Subject: 	Re: dotimes var comiler warning
Date: 	Thu, 24 Nov 2016 14:32:44 +0100
From: 	Michael Heerdegen <michael_heerdegen <at> web.de>
To: 	Andreas Röhler <andreas.roehler <at> easy-emacs.de>
CC: 	Help Gnu Emacs mailing list <help-gnu-emacs <at> gnu.org>



Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:

> when employing a form
>
> (dotimes (i erg)
>
>    ...do-something
>
>
> Compiler sends a warning "Unused lexical variable ‘i’ - whilst seems
> no way to leave out such a var.
>
> Worth a bug-report?

If none exists yet, I'm for it.  FWIW, there is a FIXME comment in the
source code already.

Yes, you can probably use `_' to suppress the warning, but I always
wondered why something called like this requires a variable to be
specified (mandatorily) at all.


Michael.

[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25017; Package emacs. (Thu, 24 Nov 2016 14:23:02 GMT) Full text and rfc822 format available.

Message #8 received at 25017 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 25017 <at> debbugs.gnu.org
Subject: Re: bug#25017: Fwd: Re: dotimes var comiler warning
Date: Thu, 24 Nov 2016 09:23:27 -0500
severity 25017 wishlist
quit

>
>  Subject:   Re: dotimes var comiler warning  
>  Date:   Thu, 24 Nov 2016 14:32:44 +0100  
>  From:   Michael Heerdegen <michael_heerdegen <at> web.de>  
>  To:   Andreas Röhler <andreas.roehler <at> easy-emacs.de>  
>  CC:   Help Gnu Emacs mailing list <help-gnu-emacs <at> gnu.org>  
>
> Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
>
>> when employing a form
>>
>> (dotimes (i erg)
>>
>>    ...do-something
>>
>>
>> Compiler sends a warning "Unused lexical variable ‘i’ - whilst seems
>> no way to leave out such a var.

So you want to do:

    (dotimes (erg)
       ...)

Or perhaps even

    (dotimes erg
       ...)

>>
>> Worth a bug-report?
>
> If none exists yet, I'm for it.  FWIW, there is a FIXME comment in the
> source code already.

The FIXME comment is unrelated to this, as far as I can tell (it's
talking about binding the variable around the optional RESULT
expression).

>
> Yes, you can probably use `_' to suppress the warning, but I always
> wondered why something called like this requires a variable to be
> specified (mandatorily) at all.

Because it's a bit nonstandard to make the *first* arg &optional?




Severity set to 'wishlist' from 'normal' Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 24 Nov 2016 14:23:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25017; Package emacs. (Thu, 24 Nov 2016 14:37:01 GMT) Full text and rfc822 format available.

Message #13 received at 25017 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: npostavs <at> users.sourceforge.net
Cc: Andreas Röhler <andreas.roehler <at> easy-emacs.de>,
 25017 <at> debbugs.gnu.org
Subject: Re: bug#25017: Fwd: Re: dotimes var comiler warning
Date: Thu, 24 Nov 2016 15:35:43 +0100
npostavs <at> users.sourceforge.net writes:

> So you want to do:
>
>     (dotimes (erg)
>        ...)
>
> Or perhaps even
>
>     (dotimes erg
>        ...)
>

Yes.

> The FIXME comment is unrelated to this, as far as I can tell (it's
> talking about binding the variable around the optional RESULT
> expression).

Oh, I think you're right.

> Because it's a bit nonstandard to make the *first* arg &optional?

It's not really an argument list we are talking about - but if it
matters, we could choose the second of the above alternatives.


Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25017; Package emacs. (Thu, 24 Nov 2016 14:45:02 GMT) Full text and rfc822 format available.

Message #16 received at 25017 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 25017 <at> debbugs.gnu.org
Subject: Re: bug#25017: Fwd: Re: dotimes var comiler warning
Date: Thu, 24 Nov 2016 15:44:04 +0100
Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:

>> (dotimes (i erg)
>>
>>    ...do-something
>>
>> Compiler sends a warning "Unused lexical variable ‘i’ - whilst seems
>> no way to leave out such a var.
>
> Yes, you can probably use `_' to suppress the warning, but I always
> wondered why something called like this requires a variable to be
> specified (mandatorily) at all.

Why is this a problem? We have the same situation with function
arguments. If you have an unused argument, you do the same:

(defun my-fun (_unused used)
  ;; code w/o _unused
  )

> Michael.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25017; Package emacs. (Thu, 24 Nov 2016 16:51:01 GMT) Full text and rfc822 format available.

Message #19 received at 25017 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Andreas Röhler <andreas.roehler <at> easy-emacs.de>,
 25017 <at> debbugs.gnu.org
Subject: Re: bug#25017: Fwd: Re: dotimes var comiler warning
Date: Thu, 24 Nov 2016 17:50:37 +0100
Michael Albinus <michael.albinus <at> gmx.de> writes:

> > Yes, you can probably use `_' to suppress the warning, but I always
> > wondered why something called like this requires a variable to be
> > specified (mandatorily) at all.
>
> Why is this a problem? We have the same situation with function
> arguments. If you have an unused argument, you do the same:
>
> (defun my-fun (_unused used)
>   ;; code w/o _unused
>   )

It's not a problem.  But it's counter-intuitive for something called
"dotimes", and it's inconvenient because not needing to bind the counter
to a variable is a very common use case, not an exception.

But yes, it's just a detail.  If what I suggest is not consent, I would
not want endless debates on this topic.


Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25017; Package emacs. (Thu, 24 Nov 2016 17:02:02 GMT) Full text and rfc822 format available.

Message #22 received at 25017 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Andreas Röhler <andreas.roehler <at> easy-emacs.de>,
 25017 <at> debbugs.gnu.org
Subject: Re: bug#25017: Fwd: Re: dotimes var comiler warning
Date: Thu, 24 Nov 2016 18:01:18 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> It's not a problem.

Though, with dynamical bindings, the expansion actually refers to the
specified variable, so if you compile e.g.

(defun f (x)
  (dotimes (_ 10)
    (cl-incf x)))

you get the warning "variable `_' not left unused".


Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25017; Package emacs. (Fri, 25 Nov 2016 06:05:02 GMT) Full text and rfc822 format available.

Message #25 received at 25017 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Michael Heerdegen <michael_heerdegen <at> web.de>, Michael Albinus
 <michael.albinus <at> gmx.de>
Cc: 25017 <at> debbugs.gnu.org
Subject: RE: bug#25017: Fwd: Re: dotimes var comiler warning
Date: Thu, 24 Nov 2016 22:03:57 -0800 (PST)
FWIW, I think that if any changes are made to dotimes they
should be in the direction of Common Lisp dotimes.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25017; Package emacs. (Sun, 27 Nov 2016 10:21:02 GMT) Full text and rfc822 format available.

Message #28 received at 25017 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 25017 <at> debbugs.gnu.org
Subject: Re: bug#25017: Fwd: Re: dotimes var comiler warning
Date: Sun, 27 Nov 2016 11:20:38 +0100
Drew Adams <drew.adams <at> oracle.com> writes:

> FWIW, I think that if any changes are made to dotimes they should be
> in the direction of Common Lisp dotimes.

How do Elisp's dotimes and Common Lisp's dotimes differ?


Thanks,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25017; Package emacs. (Sun, 27 Nov 2016 18:25:01 GMT) Full text and rfc822 format available.

Message #31 received at 25017 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 25017 <at> debbugs.gnu.org
Subject: RE: bug#25017: Fwd: Re: dotimes var comiler warning
Date: Sun, 27 Nov 2016 10:23:49 -0800 (PST)
> > FWIW, I think that if any changes are made to dotimes they
> > should be in the direction of Common Lisp dotimes.
> 
> How do Elisp's dotimes and Common Lisp's dotimes differ?

http://clhs.lisp.se/Body/m_dotime.htm

It respects `return' and `return-from'.  It allows tags
(for `go').

For purposes of this thread: As in Emacs Lisp, both VAR
and COUNT are required arguments.  In general, I'd prefer
that Emacs Lisp not diverge from but converge toward
Common Lisp.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25017; Package emacs. (Sun, 27 Nov 2016 20:13:02 GMT) Full text and rfc822 format available.

Message #34 received at 25017 <at> debbugs.gnu.org (full text, mbox):

From: Philipp Stephani <p.stephani2 <at> gmail.com>
To: Drew Adams <drew.adams <at> oracle.com>,
 Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 25017 <at> debbugs.gnu.org
Subject: Re: bug#25017: Fwd: Re: dotimes var comiler warning
Date: Sun, 27 Nov 2016 20:11:44 +0000
[Message part 1 (text/plain, inline)]
Drew Adams <drew.adams <at> oracle.com> schrieb am So., 27. Nov. 2016 um
19:25 Uhr:

> > > FWIW, I think that if any changes are made to dotimes they
> > > should be in the direction of Common Lisp dotimes.
> >
> > How do Elisp's dotimes and Common Lisp's dotimes differ?
>
> http://clhs.lisp.se/Body/m_dotime.htm
>
> It respects `return' and `return-from'.  It allows tags
> (for `go').
>

A variant of `dotimes' that supports such constructs (only the "return"
ones though) is available in cl-lib.el: `cl-dotimes'.


>
> For purposes of this thread: As in Emacs Lisp, both VAR
> and COUNT are required arguments.  In general, I'd prefer
> that Emacs Lisp not diverge from but converge toward
> Common Lisp.
>
>
>
The (implicit) decision to diverge further from Common Lisp has been made a
while ago, by prefixing the CL functions with `cl' and importing the `seq'
and `map' libraries, which provide similar functionality, but with a
different interface. Regarding third-party package, the hugely popular
`dash' library advertises itself with "No CL required." Given these
indicators, I'd expect the divergence to increase further instead of
decrease.
[Message part 2 (text/html, inline)]

Reply sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
You have taken responsibility. (Mon, 28 Nov 2016 16:33:02 GMT) Full text and rfc822 format available.

Notification sent to Andreas Röhler <andreas.roehler <at> easy-emacs.de>:
bug acknowledged by developer. (Mon, 28 Nov 2016 16:33:02 GMT) Full text and rfc822 format available.

Message #39 received at 25017-done <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Philipp Stephani <p.stephani2 <at> gmail.com>
Cc: andreas.roehler <at> easy-emacs.de, 25017-done <at> debbugs.gnu.org,
 Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#25017: Fwd: Re: dotimes var comiler warning
Date: Mon, 28 Nov 2016 17:31:49 +0100
Philipp Stephani <p.stephani2 <at> gmail.com> writes:

>  For purposes of this thread: As in Emacs Lisp, both VAR
>  and COUNT are required arguments. In general, I'd prefer
>  that Emacs Lisp not diverge from but converge toward
>  Common Lisp.
>
> The (implicit) decision to diverge further from Common Lisp has been
> made a while ago, by prefixing the CL functions with `cl' and
> importing the `seq' and `map' libraries, which provide similar
> functionality, but with a different interface.

Maybe (though, I don't think there was such decision, implicit or not -
"seq" and "map" functions also have an according prefix - I wouldn't say
we are converging are diverging to/from Common Lisp at all, but give
developers a stylistic choice).  But here were are talking about a
construct that exists in pure Elisp, and OTOH also in Common Lisp,
sharing the same name.  If there is not really a need to make the
semantics differ, I prefer to leave things as they are, because
everything else would probably be more confusing than helpful.


Regards,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25017; Package emacs. (Mon, 28 Nov 2016 16:55:02 GMT) Full text and rfc822 format available.

Message #42 received at 25017-done <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Michael Heerdegen <michael_heerdegen <at> web.de>, Philipp Stephani
 <p.stephani2 <at> gmail.com>
Cc: andreas.roehler <at> easy-emacs.de, 25017-done <at> debbugs.gnu.org
Subject: RE: bug#25017: Fwd: Re: dotimes var comiler warning
Date: Mon, 28 Nov 2016 08:54:13 -0800 (PST)
> > The (implicit) decision to diverge further from Common Lisp has
> > been made a while ago, by prefixing the CL functions with `cl' and
> > importing the `seq' and `map' libraries, which provide similar
> > functionality, but with a different interface.
> 
> Maybe (though, I don't think there was such decision, implicit or
> not - "seq" and "map" functions also have an according prefix - I
> wouldn't say we are converging are diverging to/from Common Lisp
> at all, but give developers a stylistic choice).  But here were
> are talking about a construct that exists in pure Elisp, and OTOH
> also in Common Lisp, sharing the same name.  If there is not
> really a need to make the semantics differ, I prefer to leave
> things as they are, because everything else would probably be
> more confusing than helpful.

+1.  Well put.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 27 Dec 2016 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 169 days ago.

Previous Next


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