Tuomas Lukka <[EMAIL PROTECTED]> writes:

> On 4 Aug 2000, Ariel Scolnicov wrote:
> 
> > Karl Glazebrook <[EMAIL PROTECTED]> writes:
> > 
> > > OK I will raise to the bait
> > > 
> > > I think it's a bit unfair to say that PDL people have failed to 'bite',
> > > there was quite a bit of discussion on our list after your post. Also
> > > some concern about how much of perl6 is vapourware.
> > > 
> > > I am game to take part in discussions. 
> > > 
> > > It has always been apparent to me that Numerical Python is better integrated
> > > than PDL. Some language changes in core python WERE made to accomodate it,
> > > also Python had less syntax clutter to get around.
> > > 
> > > I definitely support embedding many of the key PDL ideas into the language
> > > - they key one is a much easier syntax for a multi-dim slice. We are currently
> > > driven to
> > > 
> > > $a->slice("10:100,30:200");
> > > 
> > > compared to IDL AND NumPy: a[10:100,30:200]
> > 
> > Perl doesn't have multi-dimensional arrays (yet, I hope), but it
> > *does* spell `:' as "..", even today.  @x[7..9] is a 3-element list,
> > which I don't see as any different from @x[7:9].  Does the slice share 
> > the elements of @a in your example?
> 
> Well, first of all, 
> 
>       10:100, 30:200
> 
> is not the same: in Perl it comes out as
> 
>       10..100, 30..200
> 
>       10, 11, ... , 100, 30, 31, .., 200
> 
> whereas what we want is
> 
>       Span(10, 100), Span(30, 200)
> 
> where Span is some suitable object telling that this span is a parameter.
> There are also other syntaxes for slice we would like to have but these
> can probably be kludged.

I think we're confusing 2 separate issues here.  PDL seems to deal
with both, but let's keep them separate:

(1) Decent span objects for generating subarrays (e.g. 1:10:3 (which
    should probably be 1..10:3, or whatever the iterator sequence
    works out as).

(2) Multidimensional arrays.  Today Perl does *not* have these.  As
    Tuomas points out, the `,' operator is already too overloaded to
    separate indices.  Note: I say the Perl has no multidimensional
    arrays.  A list-of-lists is *not* a multidimensional array.  A
    multidimensional array can be *implemented* as a list-of-lists,
    but not efficiently.

Naturally, there are interesting interactions between (1) and (2),
e.g. when slicing a multidimensional array (consider, for instance,
what an operator should look like that returns the diagonal of a
square matrix).

A third issue:

(3) An "rvalue" slice is a *copy* of the elements sliced from the
    array; an "lvalue" slice consists of the elements themselves, with 
    a different indexing scheme.  Naturally, Perl should have both...


[...]

> > Regarding multi-dimensional arrays, the PDL porters are undoubtable
> > champions; what is required?
> 
> Well, the PDL distro is our answer to that ;) ;)

But Shirley Perl could make your job a little less horrible?  At the
very least, if `:' were a binary operator, you could overload it to
generate non-string slice indices.

-- 
Ariel Scolnicov        |"GCAAGAATTGAACTGTAG"            | [EMAIL PROTECTED]
Compugen Ltd.          |Tel: +972-2-6795059 (Jerusalem) \ We recycle all our Hz
72 Pinhas Rosen St.    |Tel: +972-3-7658514 (Main office)`---------------------
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555    http://3w.compugen.co.il/~ariels

Reply via email to