
Gary King wrote
Pascal Constanza wrote:
1. Support a :TEST arg for (E)CASE.
I'm not sure what this buys you over a regular cond. Case primarily exists for efficiency, no?
Hi Pascal, I see your point _but_ there is also something to be said for efficiency of human code reading and code writing, no? I'd say that case variants let the reader know that all of the tests are of the form "this" is the same as "that" for some notion of "same as" and various "that"s.
(case <this> (that-1 ...) (that-2 ...) ...)
whereas cond is saying, do an arbitrary test for each possible branch...
This may not be enough to argue for adding to / extending case...
I have mixed feelings about this. On one hand, it is a handy idiom. On the other hand, CASE (and ECASE and maybe, to some extent TYPECASE) are by now well-ingrained as efficient idioms. I would personally be happier if there was an "almost CASE" with user- controllable test, whose name didn't actually contain "CASE" at all. Unfortunately, I don't think SWITCH is a good name, either. I notice that I can't see a SELECT in the HyperSpec, maybe that would be a neutral-enough name for this sort of construct? Something along the lines of: (select (form &optional (test #'eql)) ...) With the forms following being similar to the ones used in CASE/ECASE? It is a handy idiom, in that respect and I have whipped up some in the past (though, I must admit, special-purpose ones, each time, rather than a general one). //Ingvar