On Monday, December 9, 2002, at 02:34  AM, Brent Dax wrote:
It just occurred to me that C<part> is almost a specialization of
C<sort>.  Consider the results if you assign without binding:
Which is why I really wish we had a closure-based syntax similar to sort, but I grudgingly understand the problems with that. (Heck, it's similar to C<given>, C<for>, C<sort>, C<map>, C<grep>... that's why I think it has to be a built-in, because we're really talking about variations of the same basic, painfully common algorithm.

I'd suggest if we could do >> (and <<) 'piping' operators, C<part> would become:

@data >> part /foo/, /bar/ >> @foo, @bar;

Again, though, people will keep thinking they want to write:

@data >> part { /foo/, /bar/ } >> @foo, @bar;

to look like C<map> and C<grep>.

If we had piping capable of handling splits into parallel streams we *could* do away with C<part> altogether, and have something like:

@data >> ( /foo/ >> @foo
& /bar/ >> @bar
& /zap/ >> @zap );

Where & and | would control whether you fell through to the next test? That way, C<part> really *is* just a multi-streamed grep!

[ It seems that this thread has drifted off-topic.  Perhaps a renaming
is in order? ]	
OK.

MikeL

Reply via email to