[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lengths and other stuff
From: |
Daniel Brooks |
Subject: |
Re: lengths and other stuff |
Date: |
Sun, 27 Dec 2020 15:32:23 -0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> A quick check does show that they were moved to subr.el from cl-lib.el
>> just three years ago. Nearly four now. Also that they were called
>> cl-cadar and so on. Weird.
>
> That's because they suck. They feel to me like programming in
> assembler. You're usually much better off using `nth` or `pcase` or
> `cl-destructuring-bind`, ...
Definitely. But a common enough pattern is to use list structure as if
it were a struct, with constructors and accessor methods that hide the
implementation details:
(defun make-complex (x y) (cons 'complex (cons x y))
(defun complex-x (c) (and (eq 'complex (car c)) (cadr c)))
(defun complex-y (c) (and (eq 'complex (car c)) (cddr c)))
That is, the c*r methods are good and useful predefined accessors, but
you give them appropriate names so that you're not using them
directly. That way you don't make your users remember how to use these
generic accessors with your custom data type.
db48x
- Re: Internationalize Emacs's messages (swahili), (continued)
- Re: Internationalize Emacs's messages (swahili), Tomas Hlavaty, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Alfred M. Szmidt, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Tomas Hlavaty, 2020/12/27
- lengths and other stuff, Daniel Brooks, 2020/12/27
- Re: lengths and other stuff, Lars Ingebrigtsen, 2020/12/27
- Re: lengths and other stuff, Daniel Brooks, 2020/12/27
- Re: lengths and other stuff, Lars Ingebrigtsen, 2020/12/27
- Re: lengths and other stuff, Daniel Brooks, 2020/12/27
- Re: lengths and other stuff, Stefan Monnier, 2020/12/27
- Re: lengths and other stuff, Stefan Monnier, 2020/12/27
- Re: lengths and other stuff,
Daniel Brooks <=
- Re: lengths and other stuff, Stefan Monnier, 2020/12/27
- Re: lengths and other stuff, Tomas Hlavaty, 2020/12/27
- Re: lengths and other stuff, Daniel Brooks, 2020/12/27
- Re: lengths and other stuff, Tomas Hlavaty, 2020/12/27
- Re: lengths and other stuff, Daniel Brooks, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Alfred M. Szmidt, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Tomas Hlavaty, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Alfred M. Szmidt, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Tomas Hlavaty, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Lars Ingebrigtsen, 2020/12/27