Karl Glazebrook wrote:

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

I can not agree more. It just seems terribly unnecessary.
Just allow us to directly overload some of the braces/parentheses for
objects.
I would be happy with

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

which would look like a subref call without the & in front. That
was my original DEFAULT method idea which would be called with
a

  $<object_instance>(args)

syntax. Just in case people are hung up about allowing us to overload
[] or {}. I really don't have a problem with

   $pdl[$a,:2,2:2]

having already another implied meaning for array types in perl5. After
all,
if we take natural languages as our model for perl, natural languages
are full of "exceptions to the rule". Mastering those is at least half
the fun of learning a language.


> 
> $pdl[0:$n][0][:]
> 
> would be fine as a syntax

Hm, I disagree. Too long. Comma or semicolon as separator (single
character that doesn't require to press shift!!!).

> 
> 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?

We could replace those with square brackets (returning an array ref)

  $pdl[0:$n,[0],:2]


  Christian

Reply via email to