Forum: Editorial
References: DIGIT-CHAR-P
Category: CLARIFICATION/CHANGE
Edit history: 2017-01-28, Version 1 by Michal Herda
Status: For CLiki consideration
- Problem Description:
- The output of DIGIT-CHAR-P might be confusing, as this function's return value also serves a different purpose. DIGIT-CHAR-P, aside from being a predicate, is also a converting function: it converts a digit in a given radix to its corresponding integer value.
- Proposal (DIGIT-CHAR-P-NOT-AN-ACTUAL-PREDICATE:SPLIT):
- Rename DIGIT-CHAR-P to CHAR-DIGIT and possibly make it signal an error instead of returning NIL. Create a DIGIT-CHAR-P which returns either true or false.
- Test case:
- (digit-char-p #\E 16) ;=> 14
- Rationale:
- A predicate function should be a predicate and not additionally serve as a converting function.
- Current practice:
- DIGIT-CHAR-P is used as a converting function
- Cost to Implementors:
- Tiny.
- Cost to Users:
- Incompatibility with previous uses of DIGIT-CHAR-P.
- Cost of Non-Adoption:
- Confusion coming from the fact that DIGIT-CHAR-P may be used in non-boolean contexts.
- Benefits:
- Abiding to the single responsibility principle.
- Aesthetics:
- Discussion:
- MichaĆ Herda supports DIGIT-CHAR-P-NOT-AN-ACTUAL-PREDICATE:SPLIT.
- Discussion: