On Thu, Sep 02, 2004 at 04:47:40PM -0700, Larry Wall wrote:
>     my ref[Array] @ragged2d;

What is a "ref" type exactly? Is it like a pointer in C? If so, and
based on the parameterization above, I assume that there will also be
the appropriate pointer arithmetic such that if $fido is declared as a
ref[Dog] and pointed at an array of Dogs, then $fido++ will move to the
next Dog in the array. Something like this:

        my Dog @pound;
        my ref[Dog] $fido;
        # after we've populated the @pound with Dogs ...
        loop ($fido = @pound[0]; ?$fido; $fido++) {
           $fido.bark();                
        }

Is there some other syntax to get a compact array of things?  Do I
need an attribute on the array?

> the presence of a low-level type tells Perl that it is free to
> implement the array with "compact storage", that is, with a chunk
> of memory containing contiguous (or as contiguous as practical)
> elements of the specified type without any fancy object boxing that
> typically applies to undifferentiated scalars.  (Perl tries really
> hard to make these elements look like objects when you treat them
> like objects--this is called autoboxing.)

Will it also try really hard to use compact storage or are the
low-level types just compiler hints?  (As a first approximation, could
all of the int types be implemented as Ints with appropriate
serialization?)

> To declare a multidimensional array, you add a shape parameter:
> 
>     my num @nums is shape(3);   # one dimension, @nums[0..2]
>     my int @ints is shape(4;2); # two dimensions, @ints[0..3; 0..1]

Maybe it's just my BASIC upbringing, but "shape" doesn't seem like the
right word.  Words like "dimension" and "cardinal" fit better in my
head, but I'd want them shorter and "dim" and "card" don't quite work
either ;-)

But "shape" makes me want to do something like this:

        my num @a is shape('triangle');
        my num @b is shape('octagon');
        my num @c is shape('square');

That might make sense for triangles, but not the others (unless
I'm just suffering a failure of imagination)

"size" could even work though it's vague. Maybe even "basis" though
that's not quite right either.  Or perhaps "extent"?

Anyway ...my two cents.  If "shape" is carved in stone, I'll live with
it :)

> If you wanted that C<0..2> range to mean
> 
>     @nums[0;1;2]
> 
> instead, then you need to use that C<semi> we keep mentioning:
> 
>     @nums[semi 0..2]

If I had 

        @a = (0,undef,2); 

would 

        @nums[semi @a] 

be the same as

        @nums[0;*;2]

?

> XXX It's not clear whether C<[EMAIL PROTECTED]> should return the size of the entire
> array or the size of the first dimension (or the scalar value of the
> entire array if it's really a zero-dimensional array!).  I've put
> C<[EMAIL PROTECTED]> above just in case.

hmm

my int @a is shape(3;4;5);

[EMAIL PROTECTED];;] == 3   (same as [EMAIL PROTECTED], right?)
[EMAIL PROTECTED];*;] == 4   (same as [EMAIL PROTECTED];*])
[EMAIL PROTECTED];;*] == 5   

BTW, could these also be made to work (or something similar)?

my int @b;
my int @a is shape(10;5;7);
@b = @a[*:by(2);;]              # @b is now shape(5;5;7)
@b = @a[;1,4;]                  # @b is now shape(10;2;7)
@b = @a[;(*);]                  # @b is now shape(10;7)
@b = @a[;;;*]                   # @b is now shape(10;5;7;1)
@b = @a[;;;*5]                  # @b is now shape(10;5;7;5)

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to