[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ADJUST-ARRAY-DISPLACEMENT



    Date: Fri, 12 Jun 87 17:27:22 PDT
    From: edsel!bhopal!jonl@navajo.stanford.edu (Jon L White)

    You suggest adding two new functions to Common Lisp:
	    ARRAY-DISPLACED-TO array 		[function]
	    ARRAY-DISPLACED-INDEX-OFFSET array	[Function]
    Did you overlook the function specified in the 6-Dec-85 "Clarifications"?
	    DISPLACED-ARRAY-P array 		[Function]
    "which takes an array and returns NIL and 0 if it is not displaced or the
    array displaced to and the displaced-index-offset if it is displaced."

If you code up the same example as I sent in my last message using
the function DISPLACED-ARRAY-P, you'll see that it's a lot more clumsy.
To me, the presence of these two functions makes the need for 
DISPLACED-ARRAY-P seem unnecessary while at the same time making 
code that actually needs this information look a lot better.

    Wouldn't it be much better to adopt the "Clarifications" approaches, where
    appropriate, since some, if not several, implementations have already 
    implemented them?

I certainly admit that I didn't look in the clarifications before
sending that message. I should have.

Ultimately, however, the clarifications are just one person's opinion (albeit
the opinion of one who is very highly respected). They still have to get voted
on just as do anyone else's suggestions. And while I admit that we shouldn't
try to gratuitously perturb things that people have already implemented where
it is reasonable to avoid doing so, I don't think we are obliged to 
unconditionally support an implementation's decision to introduce these 
primitives `prematurely'.

As it happens, I don't like functions with predicate-sounding names being
used for non-predicate values, so I'm not sure that I would have really
wanted to go with this clarification if I had a choice. eg, whenever I
use DIGIT-CHAR-P for value, I do
 (DEFUN DIGIT-WEIGHT (&REST ARGS) (APPLY #'DIGIT-CHAR-P ARGS))
and use DIGIT-WEIGHT instead. I find that expressions like 
 (+ (* VALUE RADIX) (DIGIT-CHAR-P CHAR))
look really awful in practice and can't bring myself to write them.