Forum: Editorial
References: CLHS 3.4.4, CLHS 3.4.5, DESTRUCTURING-BIND, CLHS term tree-structure
Category: CLARIFICATION/CHANGE
Edit history: 2004-07-20, Version 1 by Bruno Haible
Status: For CLiki consideration
- Problem Description:
- There is confusion about the meaning of a NIL element in a macro lambda list and destructuring lambda list. One should confirm or disconfirm that NIL in a destructuring lambda list (or a macro lambda list) acts as a "don't care" symbol, matching any object without causing a binding.
- Proposal (DESTRUCTURING-NIL:DISALLOW):
- Make it explicit that NIL as element of a macro lambda list or destructuring lambda list that has no lambda list keywords denotes the variable NIL, which is not useful since NIL being a constant, it cannot be bound or assigned.
- Proposal (DESTRUCTURING-NIL:ATOMIC):
- Make it explicit that NIL as element of a macro lambda list or destructuring lambda list that has no lambda list keywords is allowed and matches only the NIL object, but produces no variable bindings.
- Proposal (DESTRUCTURING-NIL:WILDCARD):
- Make it explicit that NIL as element of a macro lambda list or destructuring lambda list that has no lambda list keywords matches any object, but produces no variable bindings.
- Test case:
- (macrolet ((%m (nil) :good)) (%m nil))
(macrolet ((%m (nil) :good)) (%m t)) - Rationale:
- CLHS 3.4.4 points to ATOMIC, since "tree structure" distinguish between cons and atom, and NIL is an atom.
- Current practice:
- CLISP has been implementing DISALLOW for years and has now switched to ATOMIC.
- Cost to Implementors:
- Change the handling of macro- and destructuring lambda lists.
- Cost to Users:
- None, since relying on any of these behaviours has already been obscure.
- Cost of Non-Adoption:
- Continued confusion.
- Benefits:
- Clarity.
- Aesthetics:
- Discussion:
- Bruno Haible votes for ATOMIC, since it preserves the symmetry between the destructuring lambda lists (X . NIL) and (NIL . X), while the other proposals don't.
- Kalle Olavi Niemitalo says about WILDCARD: Why would it do that, other than in LOOP destructuring?
- Discussion: