develooper Front page | perl.perl6.language | Postings from February 2005

Lingering questions about Junctions.

Thread Next
Rod Adams
February 19, 2005 13:51
Lingering questions about Junctions.
Message ID:

Now that I've largely accepted junctions (except implicit autothreading, 
which is Bad.), I see some corners that need to be poked at in terms of 
how they fit into the language as a whole.

All of these examples assume an appropriate level of "use junctions;" is 
in effect.

 - Can junctions be used as array/hash subscripts?

In an rvalue context, this makes sense, in that you can simply return a 
junction of the deferences. But in an lvalue context, this gets dubious 
for everything except all() junctions. Consider:

    @x = 1..10;
    @x[any(4,3)] = 7;

What does @x look like now?

    @x[all(4,3,2)] = 7;

makes sense, as long as it means:

    @x[4,3,2] »=« 7;

I don't want to even think about what:

    @x[none(1,2)] = 7;


 - Can you have non-scalar junctions?

As the discussions surrounding C< .. > demonstrated, it's not that hard 
for someone to create a situation where a junction of lists might come 
into existence. But let's consider something a step beyond.

    %x = (a => 1, b => 2, c => 3) | (d => 4, e => 5, f => 6);
    @y = %x.keys;

Does this explode, or does @y have something useful in it now?

Before dismissing the concept completely, it's perfectly possible to 
create something much like a junctive hash via references:

    %x = (a => 1, b => 2, c => 3);
    %y = (d => 4, e => 5, f => 6);
    $z = one(\%x, \%y);
    @w = $z.keys;

 - What does it mean to sort a list of junctions?

    @x = any(1,6), all(2,5), one(3,4);
    @x = @x.sort;

Does sort() carp on junctions, or is it just one of the weird things you 
have to live with if you're playing with junctions?

-- Rod Adams

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About