3 ms·
Emacs does have great documentation, but those functions you linked to are a perfect example of the problem with Elisp's "standard library": the naming and conv
by b3morales 4y ago
Emacs does have great documentation, but those functions you linked to are a perfect example of the problem with Elisp's "standard library": the naming and conventions have been grown organically and at this point often feel quite arbitrary.
Some of those functions are named `<action>-sequence`. Some of them are named `seq-<action>`. Some of them are just `<action>`.
Some of them overlap (`seq-length`/`length`; `sequencep`/`seqp`; `sort`/`seq-sort`; `seq-contains-p`/`memberp`), and it's not always clear what the difference is.
Some come with caveats for specific sequences (`sort`: "Note that this function doesn’t work for all sequences; it may be used only for lists and vectors."; `length`: "If you need to compute the width of a string on display, you should use `string-width` (see Size of Displayed Text), not length, since length only counts the number of characters").
No language or library is perfect, but this kind of inconsistency is undeniably a hurdle when trying to write a program.
- Jtsummers 4y agoThe difference is actually explained. The `seq-` functions are generic. From the same document I linked to before: > The seq.el library provides the following additional sequence manipulation macros and functions, prefixed with seq-. To use them, you must first load the seq library. > All functions defined in this library are free of side-effects; i.e., they do not modify any sequence (list, vector, or string) that you pass as an argument. Unless otherwise stated, the result is a sequence of the same type as the input. For those functions that take a predicate, this should be a function of one argument. > The seq.el library can be extended to work with additional types of sequential data-structures. For that purpose, all functions are defined using cl-defgeneric. See Generic Functions, for more details about using cl-defgeneric for adding extensions. That statement occurs before the various `seq-` functions are listed and described so it's hard for me understand the claim that "it's not always clear what the difference is" when it's stated so clearly before the functions themselves. And when you get into them, like with `seq-length`, you get a statement like this: > For built-in sequence types, seq-length behaves like length. I really don't see how they could present this more clearly, what's your suggestion? Should they put flashing lights around the text?