Re: Should C and C work in C ?

2008-06-30 Thread Larry Wall
On Mon, Jun 30, 2008 at 07:25:11AM -0500, Patrick R. Michaud wrote:
: So my question is really whether or not we consider grep and 
: reverse to be universal methods in this sense also, so that
: C< $x.grep(...) > and C< $x.reverse > will work even if $x 
: isn't a value that normally does list-type operations.  
: 
: I'm suspecting that the answer is "yes, they are universal",
: but wanted to confirm it.

Confirmed.  (Though note that Str.reverse probably overrides
Any.reverse, unless we give string reversal a different name.)

Larry


Re: Should C and C work in C ?

2008-06-30 Thread Patrick R. Michaud
On Mon, Jun 30, 2008 at 07:25:11AM -0500, Patrick R. Michaud wrote:
> Moritz is correct -- in order to get ('foo').join(':') to work as
> people will expect, it was decided to define "universal" methods
> in the Any class as part of the prelude [1].

I forgot to include the reference link:

1.  http://groups.google.com/group/perl.perl6.compiler/msg/acf1cfbb16b998cf

Pm


Re: Should C and C work in C ?

2008-06-30 Thread Patrick R. Michaud
On Mon, Jun 30, 2008 at 01:43:11PM +0200, Moritz Lenz wrote:
> Ovid wrote:
> > --- On Sun, 29/6/08, Patrick R. Michaud <[EMAIL PROTECTED]> wrote:
> > 
> >> Do C and C act like the
> >> C method, in that
> >> they work for C object and not just objects of
> >> type C?
> >> 
> >> In other words,, should  C< $x.grep(...) >  work even
> >> if $x isn't normally a list type?
> > 
> > If I understand you correctly, I think you're asking if grep and map can be 
> > applied to junctions?  
> 
> I think Patrick meant something else.
> 
> The other day we had the discussion what $x.join($sep) should be,
> specifically if it should work for non-List $x. $Larry said yes, it
> should work, and the way to achieve that is to use Any.join.
> Now Patrick wants to know which of the various list methods need to be
> in Any.

Moritz is correct -- in order to get ('foo').join(':') to work as
people will expect, it was decided to define "universal" methods
in the Any class as part of the prelude [1].

So my question is really whether or not we consider grep and 
reverse to be universal methods in this sense also, so that
C< $x.grep(...) > and C< $x.reverse > will work even if $x 
isn't a value that normally does list-type operations.  

I'm suspecting that the answer is "yes, they are universal",
but wanted to confirm it.

Thanks!

Pm


Re: Should C and C work in C ?

2008-06-30 Thread Trey Harris

In a message dated Mon, 30 Jun 2008, Ovid writes:
I just noticed you included 'reverse' in that list of methods.  I 
thought junctions were inherently unordered, thus making reverse 
kind of useless (which leads me even more to believe that I've 
misunderstood the question).


Yes--Junction is a sister of Any, not a subtype of Any.  That's how 
you get the autothreading--accept Any or a subtype thereof, and when 
you get a junction, you autothread.  Accept Junction or Object and you 
can inspect the junction directly.


At least, that's how *I* think it works... :)

--
Trey Harris  http://www.lopsa.org/
President, LOPSA   -- The League of Professional System Administrators
Opinions expressed above are not necessarily those of LOPSA.


Re: Should C and C work in C ?

2008-06-30 Thread Moritz Lenz
Ovid wrote:
> --- On Sun, 29/6/08, Patrick R. Michaud <[EMAIL PROTECTED]> wrote:
> 
>> Do C and C act like the
>> C method, in that
>> they work for C object and not just objects of
>> type C?
>> 
>> In other words,, should  C< $x.grep(...) >  work even
>> if $x isn't normally a list type?
> 
> If I understand you correctly, I think you're asking if grep and map can be 
> applied to junctions?  

I think Patrick meant something else.

The other day we had the discussion what $x.join($sep) should be,
specifically if it should work for non-List $x. $Larry said yes, it
should work, and the way to achieve that is to use Any.join.
Now Patrick wants to know which of the various list methods need to be
in Any.

BTW Junctions aren't a subtype of Any, but of Object.

> If I've misunderstood, feel free to print this out and burn it :)

$rant_about_wasting_resources_and_climate_change ;-)

Moritz

-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/


Re: Should C and C work in C ?

2008-06-30 Thread Ovid
--- On Mon, 30/6/08, Ovid <[EMAIL PROTECTED]> wrote:
> --- On Sun, 29/6/08, Patrick R. Michaud
> <[EMAIL PROTECTED]> wrote:
> 
> > Do C and C act like the
> > C method, in that
> > they work for C object and not just objects
> of
> > type C?
> > 
> > In other words,, should  C< $x.grep(...) >  work
> even
> > if $x isn't normally a list type?
> 
> If I understand you correctly, I think you're asking if
> grep and map can be applied to junctions?  I would say yes. 

I just noticed you included 'reverse' in that list of methods.  I thought 
junctions were inherently unordered, thus making reverse kind of useless (which 
leads me even more to believe that I've misunderstood the question).

Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog- http://use.perl.org/~Ovid/journal/
Twitter  - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6



Re: Should C and C work in C ?

2008-06-30 Thread Ovid
--- On Sun, 29/6/08, Patrick R. Michaud <[EMAIL PROTECTED]> wrote:

> Do C and C act like the
> C method, in that
> they work for C object and not just objects of
> type C?
> 
> In other words,, should  C< $x.grep(...) >  work even
> if $x isn't normally a list type?

If I understand you correctly, I think you're asking if grep and map can be 
applied to junctions?  I would say yes.  We don't want to mutate junctions in 
place as this would break their parallelism, but I've found that I sometimes 
need to pass junctions around and build new junctions based on the values of 
old junctions.  grep and map would make that trivial.

If I've misunderstood, feel free to print this out and burn it :)

Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog- http://use.perl.org/~Ovid/journal/
Twitter  - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6