Christophe Rhodes wrote:
> [ ..... ] Both of these answers can be correct, and probably are. Certainly
> SBCL's answer is correct. I'll quote from the HyperSpec page for
> MAKE-ARRAY:
>
> If adjustable is non-nil, the array is expressly adjustable (and so
> actually adjustable); otherwise, the array is not expressly
> adjustable (and it is implementation-dependent whether the array is
> actually adjustable).
Ok. Sorry. I missed this.
> [ ..... ] What was your TYPEP call meant to achieve?
(defun foo (bar)
;; bar must be adjustable array with fill-pointer.
check-bar
...)
check-bar
first version:
(assert (and (arrayp bar) (array-has-fill-pointer-p bar) (adjustable-array-p bar)))
I think it's not very good because I have 'bar' in three
places... (annoying if I want to change variable name).
second version:
(check-type bar (and array (satisfies array-has-fill-pointer-p) (satisfies adjustable-array-p)))
.
Btw, I noticed funny effect when typespec is not valid, try:
(check-type bar (satisfies array-has-fill-pointer-p x))
^
^^^
invalid
My SBCL produces *endless* warnings...
Regards, Szymon.
|