Re: Some PDL issues (was Re: Test)

[email protected] (Karl Glazebrook)
Newsgroups perl.perl6.language.data
Message-ID <[email protected]>
Nathan Torkington wrote:
> > (1) The current
> >
> >    $pdl->slice("0:$n,(0)");
> >
> > syntax sucks.
> 
> Would:
> 
>   $pdl->[0:$n][0][:]
> 
> suffice?  I figure this would translate into something like:
> 
>   $pdl->subscript( 0, $n )
>       ->subscript( 0 )
>       ->subscript( undef, undef )
> 
> That is, you can overload [] on objects but instead of being @{}
> as it currently is (where your overload sub returns an array ref)
> you get to handle the subscript operation yourself.

Some comments:

"->" really sucks as something to routinely type in to a interactive shell
all the time. I hate it.  

$pdl[0:$n][0][:]

would be fine as a syntax

BUT we really want the subscription operation to be fast and efficient -
which means doing it with one subroutine call not 3. This is where the 
$pdl[0:$n,0,:] form wins as you can imaging the subroutine just seeing
"0:$n,0,:" in one arg.

Also another common idiom in PDL is:

$pdl[0:$n,(0),:]

where the () means - lose this dimension of size unity. I.e. make the result
MxN rather than Mx1xN. How would this be handled?


> 
> > (2) We see the need for a multidimensional, packed and typed array.
> >
> > The question is: should such an array type be part of perl6 or should it
> > be left to a module to implement such types?
> 
> I vote module.

I guess having true multidim arrays in the core would lead to a [a,b,c[
slicing syntax.

Karl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.