top | item 46953809

(no title)

tkrn | 20 days 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.

discuss

order

shakna|20 days ago

A 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.