[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why DIGITP and DIGIT-WEIGHT?
- To: Guy.Steele at CMU-10A
- Subject: Re: Why DIGITP and DIGIT-WEIGHT?
- From: Kent M. Pitman <KMP at MIT-MC>
- Date: Thu ,2 Oct 80 17:27:00 EDT
- Cc: LISP-FORUM at MIT-MC
(APPEND A ()) ; Obscure use of APPEND to copy top of list
(SUBST () () A) ; Obscure use of SUBST to copy structure
(LSH -1 -1) ; Obscure use of -1 & LSH to get max pos fixnum
(SSTATUS MACRO (PROGN I) ...) ; Obscure use of PROGN to make I EVAL
These are ugly idioms. They each have their particular application -- some
more questionable than others, but in each case, the end result is in no way
related to the name. APPEND should put things together. SUBST should do
substitution. -1 should be negative 1 -- we shouldn't have to use it for its
representation. PROGN should sequence -- it shouldn't be used to make a list
out of something that wouldn't normally be ...
Having to say (DIGITP #/8) to get a digit's weight is annoying. It looks like
a predicate. It may be a predicate -- sometimes. If I did:
... (WHILE (SETQ C (DIGITP (TYI))) ...) ...
I might want DIGITP instead of DIGIT-WEIGHT but if I were in a routine which
I knew had verified its input to be digits, I would want to say
... (LET ((W (DIGIT-WEIGHT DIGIT))) ...
... (LET ((W (DIGITP DIGIT))) ...
Indeed, I may have been passed the DIGIT from some other routine and not
know what his input radix was. I may only know that the caller wanted it
treated as a digit. Then the default argument must be explicitly given (as
36. -- sigh) and I will need
... (LET ((W (DIGITP DIGIT 36.))) ...
which is even dumber if all I want is the digit weight. I'd also like to think
that the code I was writing would work fine if there were bases above 36. Why
should that constant have to go in.
Having two functions means I can say the functionality I want and get it
straightforwardly. The issues are subtle when there is only one function and
they are straightforward if there are two. I vote for the straightforward
case. The code will be there anyway; why not give the user the entry point