On Thu, Sep 21, 2000 at 03:26:39PM -0400, Karl Glazebrook wrote:
> > [Aside: Why not make ternary-range operator into 10 :: 20 :: 2 ?]
> 
> That would work. My point is that having a stride is a fundamental
> feature in other array languages (IDL, Matlab, PDL) and would be
> useful in the perl core.

Did not use any steps more than 1 for a decade or so.  But in 80's,
when people did not believe in 10^4..10^7 speedups my algos were
claiming, I needed to actually code them in Fortran ;-).  I think I
used larger-than-1 steps that time.

But with Fortran such things are not *needed*.  Compilers are smart
enough to convert (equivalents to)

  map 3*$_, 34..67

into efficient code...

> > A proposal like this would make a nuisance into a nightmare.  Yes, it
> > looks nice, but it contradicts many rules, so in the long run it is
> > going to be a significant step back.
> > 
> > ...Unless the whole idea of cryptocontext is turned to become something else...
> 
> I am not sure what you mean by "cryptocontext"?

See p5p archives.  (Significant) switching of the meaning of operations
basing on the context looks good on paper and for small examples, but
it breaks badly in slightly more complicated situations.  The problem
is that the context is not always what you think.  Say,

  f(3*@a)

would typically be a list context - and suddently instead of 3*(1+$#a)
you get C<map 3*$_, @a>.

> I guess the motivation here is to make non-core arrays (such as PDL
> objects) look as much as possible like Perl arrays to simplify the
> appearance to users.

Why?  Currently you can make them look like references to array.  See
Math::Pari for an implementation.  Overloading '@{}' gives yet another
way to do this.

> It's really hard to explain why people should use @x[1..10] for
> perl arrays and $x->slice("1:10") for PDL arrays!

Use

  $x->[1..10]

for both.

Ilya

Reply via email to