From: Dan Starr <dvstarr@ea...> - 2007-01-28 17:24:27
Hope that I'm sending this to the right clisp address
I run my programs on different lisp compilers to make sure that the=20
code works everywhere. I tried out SBCL on my Intel-based Mac. My=20
program works fine under clisp, but SBCL choked on this:
(coerce s 'array)
I fixed it by writing my own coerce clone, but communicated the=20
apparent bug to the SBCL guys. They wrote back that you are not=20
supposed to be able to do that, according to the ANSI hyperspec. You=20
should, they wrote, only be able to write this:
(coerce s 'vector)
My question is this, perhaps splitting hairs: Is clisp correct in=20
letting you coerce 'list to 'array? Should it perhaps generate an=20
error? As of now, it is liberal and does it anyhow. The point is that=20=
I was coercing a tree and sbcl didn=92t know exactly how to do it. In =
several dimensions? Into only one dimension?
Not a big deal.
-- devious dan
From: Sam Steingold <sds@gn...> - 2007-01-29 14:36:55
Dan Starr wrote:
> Hope that I'm sending this to the right clisp address
> I run my programs on different lisp compilers to make sure that the
> code works everywhere.
> My question is this, perhaps splitting hairs: Is clisp correct in
> letting you coerce 'list to 'array?
> Should it perhaps generate an error?
> As of now, it is liberal and does it anyhow.
CLISP follows the spirit of the function COERCE and turns your list into
an array (since a vector IS an array).
in the same venue, it might have done
(coerce '(1 2 3) '(or array hash-table))
== (coerce '(1 2 3) 'array)
== (coerce '(1 2 3) 'vector)
This is a compliant extension to the standard:
does not say that the "rules" listed are exhaustive.
specifically, it does not say "if the result-type is not one of the
listed types, an error is signaled".
instead, it says "If a coercion is not possible, an error of type
type-error is signaled".
obviously, a coercion of a list to an array (specifically, to a vector)
is, indeed, possible - just not specified by the standard,
e.g., one can imagine the following compliant behavior:
(coerce '((1 2) (3 4)) '(simple-array 2)) => #2a((1 2) (3 4))
again, the issue hinges on whether the rules list is exhaustive or not.
It never says it is, so CLISP assumes it is not.
It never says it is not, so SBCL assumes it is.