2009/10/18 Tobias C. Rittweiler <tcr@...>:
>
> Compiling and loading
>
> (declaim (ftype
> (function
> (sequence unsigned-byte &key (:initial-element t)
> (:initial-contents sequence))
> (values sequence &optional))
> make-sequence-like))
> (locally
> (declare (sb-ext:muffle-conditions style-warning))
> (defun make-sequence-like
> (sequence length
> &rest keys
> &key (initial-element nil iep) (initial-contents nil icp))
> "returns a new sequence of length `length' and of the same type as `sequence'.
>
> the parameters `initial-element' and `initial-contents' specify how the new
> sequence is supposed to be initialized. only one of them can be passed at a
> time.
> "
> (declare (sb-ext:unmuffle-conditions style-warning))
> (declare (ignorable keys initial-element iep initial-contents icp))
> (apply #'sb-sequence:make-sequence-like sequence length keys)))
>
> and then trying to evaluate
>
> (make-sequence-like #(1 2) 1 :initial-element '(1 2))
>
> results in the following error
Wow.
The problem is twofold. 1: in your code, you should add &REST T to the
declaim -- as written the declaim only accepts two keyword arguments.
2: SBCL should notice the mismatch and complain about it instead of
going off the wall like it now does.
(I haven't dug in properly, but at least experimentally adding &REST T
to the declamation makes it work.)
Cheers,
-- Nikodemus
|