[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [elpa] master 96e61a9 26/26: Add packages/darkroom by merging its up
Re: [elpa] master 96e61a9 26/26: Add packages/darkroom by merging its upstream subtree
Mon, 22 Dec 2014 08:51:59 +0000
Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (darwin)
Stefan Monnier <address@hidden> writes:
>>>> + (mapc #'(lambda (w)
>>>> + (with-selected-window w
>>>> + (darkroom--set-margins)))
>>>> + (get-buffer-window-list (current-buffer))))
>>> I recommend the use of `dolist' instead of `mapc' when the body of the
>>> loop is provided by an anonymous function and we're looping over a list.
>>> If the compiler could tell that we're looping over a list, it could
>>> auto-transform the mapc call into a dolist (which is slightly more
>>> efficient), but having to expend it to a loop that handles both lists
>>> and arrays (like `mapc' does) makes the resulting code no more efficient
>>> than just using `mapc'.
>> Alright, makes sense. What if I use `(cl-loop for w in ...list...)`
>> which is my preferred cl-idiom anyway?
> Use whichever you prefer. I was just pointing out the style I tend
> to prefer, partly for efficiency reasons (and also because I haven't
> managed to plug that efficiency problem in the optimizer).
Yes, the idea came across. When it isn't "outsmarting" or premature,
it's useful to use idioms that will probably help the compiler. To use
mapc for lists in this context, all one could do is wait for some kind
type inference engine, which is probably in a more distant future.