On Tue, Dec 17, 2002 at 09:54:52AM -0800, Michael Lazzaro wrote:
> Umm... I think some of these recent messages have had typos between L2R 
> and R2L. (?)  In that people seem to have been arguing against 
> themselves.  (??)  I'll try using --> and <--.

Just to make sure I'm not one of those people, I'll clarify my terms:

I am calling this L2R:

   @b = @a --> sort --> map { $_++ } --> grep { $_ > 0 };

I don't care about the syntax at all, I just made up something that
seemed moderately clear to me.  In point of fact, I hope we DON'T use
the above syntax, or anything else where you are required to have an
operator between each element of the pipeline.

I am calling this R2L:

   @b = grep { $_ > 0 } map { $_++ } sort @a;

Note that this is just Perl5 code.


> We _must_ (for some value of "must" that is real close to being a 100% 
> drop-dead requirement) support --> (L2R), in the form of
> 
>    @a.grep( {...} )
>        .map( {...} )
>          .sort;
> 
> i.e. however else we do it, array processing functions _MUST_ exist as 
> methods of Array.  That may not be the preferred spelling, or anything 
> close to attractive, but it would be simply pathetic for it not to 
> exist.

Well, I generally agree with you, but with an important nit: they
shouldn't be members of Array, they should be members of Collection,
Array's base class.  Otherwise, what if I define an UnorderedMultiSet class and I want 
to grep over it?

Ok, let me play Devil's Advocate (*) for a moment.  Why do we need
this?  Why should these names be locked up in the Array class?  What
if I want to grep a list, or if I want to define some kind of class
for which it is meaningful to grep an instance...perhaps an
UnorderedMultiSet class.  If these functions are locked up in Array, I
will need to either derive my UnorderedMultiSet from Array
(inappropriate), use an Array internally (perhaps inconvenient), or
redefined the methods myself (wasteful).

> have to be in _addition_ to the above, not _instead_ of.  We can add 
> the Perl5-style:
> 
>     @out = sort map {...} grep {...} @a;
> 
> if we want to, but I don't think it should be given a free ride in 
> Perl6.  It's not regular (not like anything else in the language), 
> sucks up those names as globally reserved (as opposed to merely methods 
> of arrays), implies more possible wacky behaviors of curlies, and 
> cannot credibly be tortured into being OO upon @a.

Hmmm...I don't suppose that, with implicit promotion to Array, we can
get out of this with the indirect object notation, can we?  I'm not
sure what it looks like this week, but perhaps we could make a minor
requirement change (e.g., need a comma on the methods and a trailing :
on the @a) and shoehorn it into something like this:

        @out = sort map {...}, grep {...}, @a:;

--Dks

Reply via email to