You are right, I do program in LISP and love the C[AD]+R idea.
I even had my own proposal 5 years ago for improving that!
> That's right, but I would go one step further and have F(irst) and R(est), with obvious composition as follows: (using kruhft's examples from another thread)
The only problem is that the car and cdr are not the first and rest of anything, when they are just used for tree structure.
Only when the tree structure conforms to certain conventions and intent of representing a list is the car "first" and the cdr "rest".
So of course those names are fine for nested lists: (ff '((a b c) d)): the "first of the first". But in, say, an assoc list ((a . 3)) 3 is not the "rest" of anything; it's the value of the key a.
The proposed functions go with the first and rest functions, rather than replace the cddr ones.
Now let's talk about something else: the order. In caddr, the order is just a condensation of the nested application of (car (cdr (cdr ...))), in the same order: it's easy to convert between the two, both actually and mentally. However, in left to right threading syntax, it's backwards:
(flow value car car cdr (+ 1))
corresponds to
(+ 1 (cdr (car (car value))))
so it condenses like
(flow value cdaar (+ 1))
You can see someone wanting a variant which has the letters in the opposite order.
With f and r functions, you can do:
(flow value f f r (+ 1))
which is almost the backwards "ffr" you might want.
It's also pretty pointless; it's just repeating the job description of the constructors and destructor of any object that manages a resource.
Who is that for? Dummies who get it backwards? Oh, look, you're releasing in your destructor and acquiring in the destructor. Did you forget your CADR?
In C++, if the construction fails (with an exception), no other member function - not even the destructor - gets called and the resource is not acquired.
This is one reason many people think exceptions in C++ are harmful, they cause unclear implicit behavior. Much better to handle a failure explicitly outside the constructor
The earliest mention of this idea (CADR / CADRe) I’ve found is from 2012: https://groups.google.com/a/isocpp.org/g/std-proposals/c/Una...