3 ms·
> COND is basically unreadable in any Lisp, you'd very rarely see people use it today. In CL you'd have more readable options like IF, WHEN and UNLESS. I would
by kbp 9y ago
> COND is basically unreadable in any Lisp, you'd very rarely see people use it today. In CL you'd have more readable options like IF, WHEN and UNLESS.
I wouldn't say "very rarely"; COND is still used for multi-way conditionals. Virtually everyone I know would write:
(cond ((minusp x) 'negative)
((plusp x) 'positive)
(t 'zero))
Rather than:
(if (minusp x)
'negative
(if (plusp x)
'positive
'zero))
IF, WHEN, and UNLESS are generally preferred where they fit nowadays, but I wouldn't call writing them with COND "basically unreadable", either, ie:
(cond (pred then)
(t else))
(cond (pred then))
(cond ((not pred) then))
Compared to:
(if pred then else)
(when pred then)
(unless pred then)
- taeric 9y agoIndeed, I always thought COND was a construct sorely missing from other languages. Pattern matching is becoming popular for similar uses. I honestly feel it can go over board in many of the same ways though.