On Sat, Feb 12, 2005 at 03:54:57PM -0600, Rod Adams wrote:
> >>But, to extract those alternative values from an object, you do 
> >>something special to it, like call a method. Whenever you evaluate the 
> >>object as a scalar, you get a single value back. Quite probably a 
> >>reference to something much more elaborate, but a single value none the 
> >>less. When you do a C<say $obj>, C<say> is only called once.
> >
> >s/object/Junction/g above doesn't give me much grief.  Extracting
> >values from a Junction is also done by calling methods or functions.
> >
> None of which has been mentioned or defined, so I was forced to assume 
> they didn't exist.

I feel like I'm being overly pedantic here (and apologies if so), but
C<.values> had been mentioned already -- see
http://www.nntp.perl.org/group/perl.perl6.language/19128.

> >I'm not so sure it gets "worse" here -- @l.join(' ') gets evaluated
> >first, and C<join> is called only once because none of its parameters
> >are a junction.  [...]
>
> As I stated in a different message, my latest, fairly careful, 
> interpretation of S09 rendered that autothreading and junctions were not 
> directly related topics, even if I wrongly implied they were several 
> posts ago. 

Ummm, are we reading the same S09?  The one I have explicitly defines
autothreading in relation to junctions:

    In particular, if a junction is used as an argument to any routine
    (operator, closure, method, etc.), and the scalar parameter you
    are attempting to bind the argument to is inconsistent with the
    Junction type, that routine is "autothreaded", meaning the routine
    will be called automatically as many times as necessary to process
    the individual scalar elements of the junction in parallel.

The only other place where autothreading is mentioned is in the
section on "Parallelized parameters and autothreading", and even
there autothreading only applies within a C<use autoindex> pragma.

> But if it makes the rest of the discussion 
> go smoother, assume I've overwritten C<say> with a non-slurpy version 
> that otherwise does the same thing.
> 
> I would still think that the above would print 243 times. 

I agree it would be possible to create such a function.

> >Umm, what's wrong with...?        
> >
> >  $l = 'cat'|'dog'|'mouse';
> >  @extract = $l.values();     # ('cat', 'dog', 'mouse')               
> >
> >
> The fact that it didn't exist until now.
> Does this mean we can do:
> 
> @l = (any(qw/a b c d/) eq any(qw/c d e f/)).values();
> 
> and get @l == ('c','d')?            

Um, no.  C<eq> isn't an intersection operator, it's a boolean
string equivalence operator.  Junctions are not designed to
be a way to manipulate sets--that's not their intent or purpose.
To do that we would use lists, and define an intersection operation 
on lists.

The above would give you @l == (0, 1), since the result of 

    any(qw/a b c d/) eq any(qw/c d e f/)

is

    any(0,1)

I think the remaining items have been addressed in other posts, so
I'll defer to those for now.

Pm

Reply via email to