all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* The FIXME in `dotimes'
@ 2022-09-07 10:22 Philip Kaludercic
  2022-09-07 12:13 ` Mattias Engdegård
  0 siblings, 1 reply; 9+ messages in thread
From: Philip Kaludercic @ 2022-09-07 10:22 UTC (permalink / raw)
  To: emacs-devel


I've always been wondering about this comment in the `dotimes' macro:

  ;; FIXME: This cost disappears in byte-compiled lexical-binding files.
  (let ((temp '--dotimes-limit--)
    ...

It appears to have been written 11 years ago, when lexical binding was
not that wide-spread.  Has the time come to follow the recommendation?



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

* Re: The FIXME in `dotimes'
  2022-09-07 10:22 The FIXME in `dotimes' Philip Kaludercic
@ 2022-09-07 12:13 ` Mattias Engdegård
  2022-09-07 13:35   ` Philip Kaludercic
  2022-09-07 13:37   ` Philip Kaludercic
  0 siblings, 2 replies; 9+ messages in thread
From: Mattias Engdegård @ 2022-09-07 12:13 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: emacs-devel

7 sep. 2022 kl. 12.22 skrev Philip Kaludercic <philipk@posteo.net>:

> I've always been wondering about this comment in the `dotimes' macro:
> 
>  ;; FIXME: This cost disappears in byte-compiled lexical-binding files.

Wonder no more, it's gone! Thanks for the tip.




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

* Re: The FIXME in `dotimes'
  2022-09-07 12:13 ` Mattias Engdegård
@ 2022-09-07 13:35   ` Philip Kaludercic
  2022-09-07 13:37   ` Philip Kaludercic
  1 sibling, 0 replies; 9+ messages in thread
From: Philip Kaludercic @ 2022-09-07 13:35 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel

Mattias Engdegård <mattiase@acm.org> writes:

> 7 sep. 2022 kl. 12.22 skrev Philip Kaludercic <philipk@posteo.net>:
>
>> I've always been wondering about this comment in the `dotimes' macro:
>> 
>>  ;; FIXME: This cost disappears in byte-compiled lexical-binding files.
>
> Wonder no more, it's gone! Thanks for the tip.

Looks good, thanks for the change.



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

* Re: The FIXME in `dotimes'
  2022-09-07 12:13 ` Mattias Engdegård
  2022-09-07 13:35   ` Philip Kaludercic
@ 2022-09-07 13:37   ` Philip Kaludercic
  2022-09-07 14:08     ` Mattias Engdegård
  1 sibling, 1 reply; 9+ messages in thread
From: Philip Kaludercic @ 2022-09-07 13:37 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel

Mattias Engdegård <mattiase@acm.org> writes:

> 7 sep. 2022 kl. 12.22 skrev Philip Kaludercic <philipk@posteo.net>:
>
>> I've always been wondering about this comment in the `dotimes' macro:
>> 
>>  ;; FIXME: This cost disappears in byte-compiled lexical-binding files.
>
> Wonder no more, it's gone! Thanks for the tip.

On a related note, I have been wondering if it would make sense to
extend `dotimes' to be usable without a variable, if it isn't required.
So that either

   (dotimes (count) ...)

or

   (dotimes count ...)

do the same as

   (dotimes (_ count) ...)

?



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

* Re: The FIXME in `dotimes'
  2022-09-07 13:37   ` Philip Kaludercic
@ 2022-09-07 14:08     ` Mattias Engdegård
  2022-09-07 14:19       ` Philip Kaludercic
  0 siblings, 1 reply; 9+ messages in thread
From: Mattias Engdegård @ 2022-09-07 14:08 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: emacs-devel

7 sep. 2022 kl. 15.37 skrev Philip Kaludercic <philipk@posteo.net>:

>   (dotimes (count) ...)

Lisp syntax rarely make the first element optional, and in this case it's both the first and the last one:

  (dotimes ([VAR] COUNT [RESULT]) BODY...)

which is a bit alien, and it's perhaps not worth the trouble for just omitting an underscore?

>   (dotimes count ...)

That wouldn't allow for arbitrary expressions so it's of limited utility (and Lisp-alien, again). There's also the risk that someone will eventually replace a variable by a function call, turning (dotimes x ...) into (dotimes (f x) ...).




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

* Re: The FIXME in `dotimes'
  2022-09-07 14:08     ` Mattias Engdegård
@ 2022-09-07 14:19       ` Philip Kaludercic
  2022-09-07 14:29         ` Robert Pluim
  2022-09-07 15:18         ` [External] : " Drew Adams
  0 siblings, 2 replies; 9+ messages in thread
From: Philip Kaludercic @ 2022-09-07 14:19 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel

Mattias Engdegård <mattiase@acm.org> writes:

> 7 sep. 2022 kl. 15.37 skrev Philip Kaludercic <philipk@posteo.net>:
>
>>   (dotimes (count) ...)
>
> Lisp syntax rarely make the first element optional, and in this case
> it's both the first and the last one:
>
>   (dotimes ([VAR] COUNT [RESULT]) BODY...)
>
> which is a bit alien, and it's perhaps not worth the trouble for just
> omitting an underscore?
>
>>   (dotimes count ...)
>
> That wouldn't allow for arbitrary expressions so it's of limited
> utility (and Lisp-alien, again). There's also the risk that someone
> will eventually replace a variable by a function call, turning
> (dotimes x ...) into (dotimes (f x) ...).

I agree, the idea was not well thought out and not worth the
complication.



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

* Re: The FIXME in `dotimes'
  2022-09-07 14:19       ` Philip Kaludercic
@ 2022-09-07 14:29         ` Robert Pluim
  2022-09-07 15:18         ` [External] : " Drew Adams
  1 sibling, 0 replies; 9+ messages in thread
From: Robert Pluim @ 2022-09-07 14:29 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Mattias Engdegård, emacs-devel

>>>>> On Wed, 07 Sep 2022 14:19:46 +0000, Philip Kaludercic <philipk@posteo.net> said:

    Philip> Mattias Engdegård <mattiase@acm.org> writes:
    >> 7 sep. 2022 kl. 15.37 skrev Philip Kaludercic <philipk@posteo.net>:
    >> 
    >>> (dotimes (count) ...)
    >> 
    >> Lisp syntax rarely make the first element optional, and in this case
    >> it's both the first and the last one:
    >> 
    >> (dotimes ([VAR] COUNT [RESULT]) BODY...)
    >> 
    >> which is a bit alien, and it's perhaps not worth the trouble for just
    >> omitting an underscore?
    >> 
    >>> (dotimes count ...)
    >> 
    >> That wouldn't allow for arbitrary expressions so it's of limited
    >> utility (and Lisp-alien, again). There's also the risk that someone
    >> will eventually replace a variable by a function call, turning
    >> (dotimes x ...) into (dotimes (f x) ...).

    Philip> I agree, the idea was not well thought out and not worth the
    Philip> complication.

Surely the goal here should be to borrow a name from other languages,
but have the result behave differently?

(defmacro range (count &rest body)

😜

Robert
-- 



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

* RE: [External] : Re: The FIXME in `dotimes'
  2022-09-07 14:19       ` Philip Kaludercic
  2022-09-07 14:29         ` Robert Pluim
@ 2022-09-07 15:18         ` Drew Adams
  2022-09-07 15:26           ` Philip Kaludercic
  1 sibling, 1 reply; 9+ messages in thread
From: Drew Adams @ 2022-09-07 15:18 UTC (permalink / raw)
  To: Philip Kaludercic, Mattias Engdegård; +Cc: emacs-devel@gnu.org

> >>   (dotimes (count) ...)
> >
> > Lisp syntax rarely make the first element optional, and in this case
> > it's both the first and the last one:
> >
> >   (dotimes ([VAR] COUNT [RESULT]) BODY...)
> >
> > which is a bit alien, and it's perhaps not worth the trouble for just
> > omitting an underscore?
> >
> >>   (dotimes count ...)
> >
> > That wouldn't allow for arbitrary expressions so it's of limited
> > utility (and Lisp-alien, again). There's also the risk that someone
> > will eventually replace a variable by a function call, turning
> > (dotimes x ...) into (dotimes (f x) ...).
> 
> I agree, the idea was not well thought out and not worth the
> complication.

In addition to what's been said - It's not bad,
other things being equal, to keep it more or
less in sync with what it's taken from, which
is Common Lisp DOTIMES (and which apparently
was inspired by Interlisp's RPTQ).


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

* Re: [External] : Re: The FIXME in `dotimes'
  2022-09-07 15:18         ` [External] : " Drew Adams
@ 2022-09-07 15:26           ` Philip Kaludercic
  0 siblings, 0 replies; 9+ messages in thread
From: Philip Kaludercic @ 2022-09-07 15:26 UTC (permalink / raw)
  To: Drew Adams; +Cc: Mattias Engdegård, emacs-devel@gnu.org

Drew Adams <drew.adams@oracle.com> writes:

>> >>   (dotimes (count) ...)
>> >
>> > Lisp syntax rarely make the first element optional, and in this case
>> > it's both the first and the last one:
>> >
>> >   (dotimes ([VAR] COUNT [RESULT]) BODY...)
>> >
>> > which is a bit alien, and it's perhaps not worth the trouble for just
>> > omitting an underscore?
>> >
>> >>   (dotimes count ...)
>> >
>> > That wouldn't allow for arbitrary expressions so it's of limited
>> > utility (and Lisp-alien, again). There's also the risk that someone
>> > will eventually replace a variable by a function call, turning
>> > (dotimes x ...) into (dotimes (f x) ...).
>> 
>> I agree, the idea was not well thought out and not worth the
>> complication.
>
> In addition to what's been said - It's not bad,
> other things being equal, to keep it more or
> less in sync with what it's taken from, which
> is Common Lisp DOTIMES (and which apparently
> was inspired by Interlisp's RPTQ).

Interesting, I was not familiar with this history:

    (RPT n form)                                            [Function]

    Evaluates the expression form, n times. Returns the value of the last
    evaluation. If n < 6, form is not evaluated, and RPT returns NIL.
    Before each evaluation, the local variable RPTN is bound to the number
    of evaluations yet to take place. This variable can be referenced within
    form. For example, (RPT 10 '(PRINT RPTN)) will print the numbers 10, 9,
    • • • 1, and * return 1,

    (RPTQ n FORMi form 2 ... form n )       [NLambda NoSp read Function]

    Nlambda-nospread version of RPT: n is evaluated, form, are noL Returns
    the value of the last evaluation of form n .

From: https://archive.org/details/bitsavers_xeroxinternceManualOct1983_52302609/page/n119/mode/2up



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

end of thread, other threads:[~2022-09-07 15:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-07 10:22 The FIXME in `dotimes' Philip Kaludercic
2022-09-07 12:13 ` Mattias Engdegård
2022-09-07 13:35   ` Philip Kaludercic
2022-09-07 13:37   ` Philip Kaludercic
2022-09-07 14:08     ` Mattias Engdegård
2022-09-07 14:19       ` Philip Kaludercic
2022-09-07 14:29         ` Robert Pluim
2022-09-07 15:18         ` [External] : " Drew Adams
2022-09-07 15:26           ` Philip Kaludercic

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.