SRFI-10 syntax vs. #nA syntax Aubrey Jaffer (03 Jan 2005 05:23 UTC)
Re: SRFI-10 syntax vs. #nA syntax bear (03 Jan 2005 06:01 UTC)
Re: SRFI-10 syntax vs. #nA syntax Per Bothner (03 Jan 2005 06:37 UTC)
Re: SRFI-10 syntax vs. #nA syntax Aubrey Jaffer (03 Jan 2005 19:16 UTC)
Re: SRFI-10 syntax vs. #nA syntax Bradd W. Szonye (04 Jan 2005 22:28 UTC)
Re: SRFI-10 syntax vs. #nA syntax Per Bothner (04 Jan 2005 23:03 UTC)
Re: SRFI-10 syntax vs. #nA syntax Bradd W. Szonye (05 Jan 2005 01:59 UTC)
Re: SRFI-10 syntax vs. #nA syntax Per Bothner (05 Jan 2005 02:13 UTC)
Re: SRFI-10 syntax vs. #nA syntax Bradd W. Szonye (05 Jan 2005 03:08 UTC)
Re: SRFI-10 syntax vs. #nA syntax Per Bothner (05 Jan 2005 03:39 UTC)
Re: SRFI-10 syntax vs. #nA syntax Shiro Kawai (05 Jan 2005 02:39 UTC)
Re: SRFI-10 syntax vs. #nA syntax Bradd W. Szonye (05 Jan 2005 02:48 UTC)
Re: SRFI-10 syntax vs. #nA syntax Taylor Campbell (03 Jan 2005 22:40 UTC)
Re: SRFI-10 syntax vs. #nA syntax Bradd W. Szonye (05 Jan 2005 00:07 UTC)
Re: SRFI-10 syntax vs. #nA syntax Matthias Radestock (05 Jan 2005 01:25 UTC)
Re: SRFI-10 syntax vs. #nA syntax Bradd W. Szonye (05 Jan 2005 02:41 UTC)
Re: SRFI-10 syntax vs. #nA syntax Taylor Campbell (05 Jan 2005 02:52 UTC)
Re: SRFI-10 syntax vs. #nA syntax Aubrey Jaffer (05 Jan 2005 03:25 UTC)
Re: SRFI-10 syntax vs. #nA syntax Bradd W. Szonye (05 Jan 2005 03:54 UTC)

Re: SRFI-10 syntax vs. #nA syntax Per Bothner 05 Jan 2005 03:39 UTC

Bradd W. Szonye wrote:

> Per Bothner wrote:
>
>>In APL, a rank-0 array is the same as a scalar.  In Scheme, it would
>>be difficult to make them the same.  One reason is mutability: a
>>rank-0 array in Scheme and Common Lisp is actually a cell that
>>contains a mutable value.
>
>
> That may be true in Common Lisp (I don't know it well enough to judge),
> but it's not currently true in RnRS+SRFI Scheme. As far as I know, only
> SRFI 47 mentions rank-0 arrays at all, and it uses 0 rank to describe
> all non-array values. That's closer to the APL meaning.

Saying that the array-rank function returns 0 for a non-array is very
different from saying that arrays of rank 0 are the same thing as
scalars.

They are different, for Common Lisp, and any consistent interpretation
of SRFI-47 *or* SRFI-25.  See below.

>>Even thpugh we talking about literals which are upposed to be
>>immutable, that doesn't solve the problem whether the dereferencing is
>>automatic or not: a 0-rank mutable array is a cell, which is different
>>from the value stored in it.  I.e. getting its value requires some
>>kind of array-ref function call.  An immutable value is one where
>>setting is prohibited (undefined), but getting uses the same functions
>>as for accessing a mutable value.  Hence,  scalar cannot be equivalent
>>to a rank-0 array in Scheme, even though it is the same in APL.
>
>
> Huh? I can't make any sense out of this. Scheme does not /define/ a
> rank-0 array as a boxed value; Scheme doesn't define arrays at all. And
> the "boxedness" of a rank-0 array cannot be fundamental, since APL
> equates rank-0 arrays and scalars.
>
> I don't see how you reach your conclusion (rank-0 arrays aren't scalars
> in Scheme) without assuming it as a premise. Why must rank-0 arrays be
> boxed values (cells)? That's not self-evident, nor does it seem useful,
> especially since APL allegedly works differently.

In APL arrays are immutable.  An APL array contains a number of values,
where the number is equal to the product of the dimensions.  That means
that a rank-0 array contains 1 value, but since the array is immutable
we can treat the rank-0 array as equivalent to its contained value.

In Scheme (i.e. in SRFI-25 or SRFI-47) and Common Lisp arrays are
mutable.  A Scheme array contains a number of "locations" (or
"cells" or "places"), where the number is equal to the product of the
dimensions.  Each location contains a value; if the array is mutable
(the normal case) then the contained value may be changed using
array-set!  Hence we must distinguish between the location and the
value stored in it.  A rank-0 array contains 1 location, which for
consistency must also be mutable (except for literal arrays).   Hence,
a rank-0 array is not equivalent to the value stored in its location.
--
	--Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/