On Wed, 30 Aug 2000, Nathan Wiger wrote:

> RFC 164 v2 has a new syntax that lets you do the above or, if you want:
> 
>    $this = s/foo/bar/, $that;
>    @these = s/foo/bar/, @those;
> 
> See RFC 164 v2, all this is supported, as well as this:
> 
>    @str =~ s/foo/bar/;
> 
> Which has been a pipe dream for some time.

For this, I say we should look for a better approach. I believe Damian
Conway has actually proposed that the any and all operators of his
Quantum::Superposition module be added to perl6 (because they do require
extensive hacks to builtin functions like substr, etc

For those of you not familiar with his QS module, it basically allows you
to store an array in a string, and perform operations on all of the
elements at once.

So instead of:
foreach (@a) {
  s/a+/a/;
}

or even:
@a = s/a+/a/, @a;

one could do:
$list = all(@a);
$list =~ s/a+/a/;

and depending upon additional extensions:
$list = all(@a) =~ s/a+/a/;

Yes, it is two lines, and seems to go against the core essence of perl's
heritage. However, there are many other great benefits that are included
in the Quantum::Superposition (stuff that is entirely unrelated to the
topic of this list.) If Damian does get his way, you can perform any
operation on all of the elements of an array without looping
constructs. And as an added benefit, it even provides the opportunity for
parallel computing (either in the far-distant future with Quantum
Computing, or even the simplistic idea of splitting a 10_000 element array
accross two proc's).

Basically, the argument is that you could theoretically do @a =~ s/a+/a/
with QS, along with many other things. So perhaps, imo, it would be best
to just let QS handle it.

Mike

Reply via email to