unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25017: Fwd: Re: dotimes var comiler warning
       [not found] <878ts957gj.fsf@web.de>
@ 2016-11-24 14:10 ` Andreas Röhler
  2016-11-24 14:23   ` npostavs
  2016-11-24 14:44   ` Michael Albinus
  0 siblings, 2 replies; 12+ messages in thread
From: Andreas Röhler @ 2016-11-24 14:10 UTC (permalink / raw)
  To: 25017

[-- Attachment #1: Type: text/plain, Size: 843 bytes --]

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@web.de>
To: 	Andreas Röhler <andreas.roehler@easy-emacs.de>
CC: 	Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>



Andreas Röhler <andreas.roehler@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.


[-- Attachment #2: Type: text/html, Size: 2271 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-24 14:10 ` bug#25017: Fwd: Re: dotimes var comiler warning Andreas Röhler
@ 2016-11-24 14:23   ` npostavs
  2016-11-24 14:35     ` Michael Heerdegen
  2016-11-24 14:44   ` Michael Albinus
  1 sibling, 1 reply; 12+ messages in thread
From: npostavs @ 2016-11-24 14:23 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: Michael Heerdegen, 25017

severity 25017 wishlist
quit

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





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-24 14:23   ` npostavs
@ 2016-11-24 14:35     ` Michael Heerdegen
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Heerdegen @ 2016-11-24 14:35 UTC (permalink / raw)
  To: npostavs; +Cc: 25017

npostavs@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-24 14:10 ` bug#25017: Fwd: Re: dotimes var comiler warning Andreas Röhler
  2016-11-24 14:23   ` npostavs
@ 2016-11-24 14:44   ` Michael Albinus
  2016-11-24 16:50     ` Michael Heerdegen
  1 sibling, 1 reply; 12+ messages in thread
From: Michael Albinus @ 2016-11-24 14:44 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: 25017

Andreas Röhler <andreas.roehler@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-24 14:44   ` Michael Albinus
@ 2016-11-24 16:50     ` Michael Heerdegen
  2016-11-24 17:01       ` Michael Heerdegen
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Heerdegen @ 2016-11-24 16:50 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 25017

Michael Albinus <michael.albinus@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-24 16:50     ` Michael Heerdegen
@ 2016-11-24 17:01       ` Michael Heerdegen
  2016-11-25  6:03         ` Drew Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Heerdegen @ 2016-11-24 17:01 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 25017

Michael Heerdegen <michael_heerdegen@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-24 17:01       ` Michael Heerdegen
@ 2016-11-25  6:03         ` Drew Adams
  2016-11-27 10:20           ` Michael Heerdegen
  0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2016-11-25  6:03 UTC (permalink / raw)
  To: Michael Heerdegen, Michael Albinus; +Cc: 25017

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





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-25  6:03         ` Drew Adams
@ 2016-11-27 10:20           ` Michael Heerdegen
  2016-11-27 18:23             ` Drew Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Heerdegen @ 2016-11-27 10:20 UTC (permalink / raw)
  To: Drew Adams; +Cc: 25017

Drew Adams <drew.adams@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-27 10:20           ` Michael Heerdegen
@ 2016-11-27 18:23             ` Drew Adams
  2016-11-27 20:11               ` Philipp Stephani
  0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2016-11-27 18:23 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 25017

> > 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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-27 18:23             ` Drew Adams
@ 2016-11-27 20:11               ` Philipp Stephani
  2016-11-28 16:31                 ` Michael Heerdegen
  0 siblings, 1 reply; 12+ messages in thread
From: Philipp Stephani @ 2016-11-27 20:11 UTC (permalink / raw)
  To: Drew Adams, Michael Heerdegen; +Cc: 25017

[-- Attachment #1: Type: text/plain, Size: 1148 bytes --]

Drew Adams <drew.adams@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.

[-- Attachment #2: Type: text/html, Size: 2103 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-27 20:11               ` Philipp Stephani
@ 2016-11-28 16:31                 ` Michael Heerdegen
  2016-11-28 16:54                   ` Drew Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Heerdegen @ 2016-11-28 16:31 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: 25017-done

Philipp Stephani <p.stephani2@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-28 16:31                 ` Michael Heerdegen
@ 2016-11-28 16:54                   ` Drew Adams
  0 siblings, 0 replies; 12+ messages in thread
From: Drew Adams @ 2016-11-28 16:54 UTC (permalink / raw)
  To: Michael Heerdegen, Philipp Stephani; +Cc: 25017-done

> > 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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-11-28 16:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <878ts957gj.fsf@web.de>
2016-11-24 14:10 ` bug#25017: Fwd: Re: dotimes var comiler warning Andreas Röhler
2016-11-24 14:23   ` npostavs
2016-11-24 14:35     ` Michael Heerdegen
2016-11-24 14:44   ` Michael Albinus
2016-11-24 16:50     ` Michael Heerdegen
2016-11-24 17:01       ` Michael Heerdegen
2016-11-25  6:03         ` Drew Adams
2016-11-27 10:20           ` Michael Heerdegen
2016-11-27 18:23             ` Drew Adams
2016-11-27 20:11               ` Philipp Stephani
2016-11-28 16:31                 ` Michael Heerdegen
2016-11-28 16:54                   ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).