bbatsov / emacs-lisp-style-guide

A community-driven Emacs Lisp style guide
1.08k stars 53 forks source link

Add section on lists #45

Closed Ambrevar closed 6 years ago

Ambrevar commented 7 years ago

Update on this?

bbatsov commented 6 years ago

Oh, I totally missed this PR. I think it'd be much better to recommend the use of the modern seq library, which was released a couple of years ago and is now part of Emacs.

Ambrevar commented 6 years ago

seq has, in my opinion, a slightly different use case: it's for manipulating list with predicates (e.g. filtering).

dolist is more of a control structure for looping: it does not necessarily return a list.

Anyways, we can always mention both.

bbatsov commented 6 years ago

I mostly mentioned this, because of your second example. Generally I would not have anyone use mapcar or mapc at this point (even those in seq they simply have better named aliases).

Fuco1 commented 6 years ago

There is a slight hit because for example seq-do does not alias to mapc but instead calls it directly because of the generic implementation. But this is in 99.99% of cases irrelevant and I agree seq-each makes more sense than mapc.

Ambrevar commented 6 years ago

Fair enough. Should I adapt the pull request with your suggestions then?

Fuco1 commented 6 years ago

@Ambrevar Please do, thanks!

Ambrevar commented 6 years ago

I've replaced mapc with seq-do in all examples.

bbatsov commented 6 years ago

Thanks! This section can be extract quite a lot, but that's as good start as any.