5 ms·
Good points. I don't think pairs are a code smell when used reasonably in situations where a pair of two values makes sense, like in your make-hash example. Ide
by tkrn 7mo ago
Good points. I don't think pairs are a code smell when used reasonably in situations where a pair of two values makes sense, like in your make-hash example. Ideally though I'd like to have a real, distinct (immutable) pair/association type separate from the cons/list and maybe use the dot syntax for that instead.
Deeply nested pair & list constructs that need to be unpacked with complex car/cdr combinations is what IMHO gets messy and I take the appearance of cddar & co in code as a sign that I should start thinking about using proper data structures.
- shakna 7mo agoA distinct and immutable pair is... A pair. (eq? (pair? '(A . B)) #t) (eq? (pair? (list 1 2 3)) #f) But agree you probably want list-ref instead of cddr and friends.