all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* dotimes var comiler warning
@ 2016-11-24 12:47 Andreas Röhler
  2016-11-24 12:53 ` Joost Kremers
  2016-11-24 13:32 ` Michael Heerdegen
  0 siblings, 2 replies; 19+ messages in thread
From: Andreas Röhler @ 2016-11-24 12:47 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hallo,

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?

Thanks,

Andreas






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

* Re: dotimes var comiler warning
  2016-11-24 12:47 dotimes var comiler warning Andreas Röhler
@ 2016-11-24 12:53 ` Joost Kremers
  2016-11-24 13:59   ` Andreas Röhler
  2016-11-24 13:32 ` Michael Heerdegen
  1 sibling, 1 reply; 19+ messages in thread
From: Joost Kremers @ 2016-11-24 12:53 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: Help Gnu Emacs mailing list


On Thu, Nov 24 2016, Andreas Röhler wrote:
> 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.

This seems to work:

    (dotimes (_ erg)
      ...)

(info "(elisp) Using Lexical Binding") says:

,----
|    (To silence byte-compiler warnings about unused variables, 
     just use a
| variable name that start with an underscore.  The byte-compiler
| interprets this as an indication that this is a variable known 
  not to be
| used.)
`----

(Very bottom of the page)

HTH


-- 
Joost Kremers
Life has its moments



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

* Re: dotimes var comiler warning
  2016-11-24 12:47 dotimes var comiler warning Andreas Röhler
  2016-11-24 12:53 ` Joost Kremers
@ 2016-11-24 13:32 ` Michael Heerdegen
  2016-11-24 14:10   ` bug#25017: Fwd: " Andreas Röhler
                     ` (2 more replies)
  1 sibling, 3 replies; 19+ messages in thread
From: Michael Heerdegen @ 2016-11-24 13:32 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: Help Gnu Emacs mailing list

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.



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

* Re: dotimes var comiler warning
  2016-11-24 12:53 ` Joost Kremers
@ 2016-11-24 13:59   ` Andreas Röhler
  0 siblings, 0 replies; 19+ messages in thread
From: Andreas Röhler @ 2016-11-24 13:59 UTC (permalink / raw)
  To: Joost Kremers; +Cc: Help Gnu Emacs mailing list



On 24.11.2016 13:53, Joost Kremers wrote:
>
> On Thu, Nov 24 2016, Andreas Röhler wrote:
>> 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.
>
> This seems to work:
>
>    (dotimes (_ erg)
>      ...)
>
> (info "(elisp) Using Lexical Binding") says:
>
> ,----
> |    (To silence byte-compiler warnings about unused variables,     
> just use a
> | variable name that start with an underscore.  The byte-compiler
> | interprets this as an indication that this is a variable known  not 
> to be
> | used.)
> `----
>
> (Very bottom of the page)
>
> HTH
>
>

Thanks!




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

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-24 13:32 ` Michael Heerdegen
@ 2016-11-24 14:10   ` Andreas Röhler
  2016-11-24 14:23     ` npostavs
  2016-11-24 14:44     ` Michael Albinus
  2016-11-24 14:14   ` Andreas Röhler
  2016-11-24 20:51   ` Emanuel Berg
  2 siblings, 2 replies; 19+ 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] 19+ messages in thread

* Re: dotimes var comiler warning
  2016-11-24 13:32 ` Michael Heerdegen
  2016-11-24 14:10   ` bug#25017: Fwd: " Andreas Röhler
@ 2016-11-24 14:14   ` Andreas Röhler
  2016-12-01 23:08     ` Emanuel Berg
  2016-11-24 20:51   ` Emanuel Berg
  2 siblings, 1 reply; 19+ messages in thread
From: Andreas Röhler @ 2016-11-24 14:14 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Help Gnu Emacs mailing list



On 24.11.2016 14:32, Michael Heerdegen wrote:
> 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.

Done, thanks. It's #25017



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

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-24 14:10   ` bug#25017: Fwd: " 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; 19+ 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] 19+ 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; 19+ 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] 19+ messages in thread

* bug#25017: Fwd: Re: dotimes var comiler warning
  2016-11-24 14:10   ` bug#25017: Fwd: " 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; 19+ 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] 19+ 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; 19+ 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] 19+ 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; 19+ 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] 19+ messages in thread

* Re: dotimes var comiler warning
  2016-11-24 13:32 ` Michael Heerdegen
  2016-11-24 14:10   ` bug#25017: Fwd: " Andreas Röhler
  2016-11-24 14:14   ` Andreas Röhler
@ 2016-11-24 20:51   ` Emanuel Berg
  2 siblings, 0 replies; 19+ messages in thread
From: Emanuel Berg @ 2016-11-24 20:51 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

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

What about:

    (cl-loop do (message "High Five") repeat 4)

?

-- 
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
                   - so far: 26 Blogomatic articles -                   




^ permalink raw reply	[flat|nested] 19+ 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; 19+ 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] 19+ 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; 19+ 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] 19+ 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; 19+ 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] 19+ 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; 19+ 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] 19+ 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; 19+ 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] 19+ 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; 19+ 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] 19+ messages in thread

* Re: dotimes var comiler warning
  2016-11-24 14:14   ` Andreas Röhler
@ 2016-12-01 23:08     ` Emanuel Berg
  0 siblings, 0 replies; 19+ messages in thread
From: Emanuel Berg @ 2016-12-01 23:08 UTC (permalink / raw)
  To: help-gnu-emacs

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.
>
> Done, thanks. It's #25017

What about:

    (cl-loop do (message "High Five") repeat 4)

?

-- 
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
                   - so far: 26 Blogomatic articles -                   




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

end of thread, other threads:[~2016-12-01 23:08 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-24 12:47 dotimes var comiler warning Andreas Röhler
2016-11-24 12:53 ` Joost Kremers
2016-11-24 13:59   ` Andreas Röhler
2016-11-24 13:32 ` Michael Heerdegen
2016-11-24 14:10   ` bug#25017: Fwd: " 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
2016-11-24 14:14   ` Andreas Röhler
2016-12-01 23:08     ` Emanuel Berg
2016-11-24 20:51   ` Emanuel Berg

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.