On Sun, 20 Feb 2005 03:17:19 -0600, [EMAIL PROTECTED] (Rod Adams) wrote:
> --------------020209010404060902000407
> Content-Type: text/plain; charset=windows-1252; format=flowed
> Content-Transfer-Encoding: 7bit
> 
> Nigel Sandever wrote:
> 
> >On Sat, 19 Feb 2005 18:42:36 +1100, [EMAIL PROTECTED] (Damian Conway) wrote:
> >
> >>The Awesome Power of Junctions:
> >>    
> >
> Well, that was one of my stumbling blocks early on. They don't really 
> give you the power to do anything you couldn't previously do. They just 
> make certain things a lot easier to do.
> 
> But I'll take a whack at giving you something non-trivial to do without 
> junctions:
> 
>     $re1 = /^ <-[x]>* x <-[x]>* $/; # match a string with exactly one 
[SNIP]
> 
> And all seven of these can be used as any stored RE can:
> 
>     if $x ~~ $re6 {...};
>     given $x {
>        when $re5 {...}
>        when 'santa' {...}
>        when ($re1 | $re3) & $re3 {...}
>     }
> 
<SNIP]
>
> So what have we gained here? The ability to join several RE's together, 
> into something that still acts like a single RE. Show me the equivalent 
> code without junctions, and then we'll compare the power of junctions.
> 

By the power of a single good example, you can now count me amongst the 
convinced. 

>
> btw, the examples above assume the ability to store a junction. So you 
> either have to 'use junctions;', or convince Larry to rescind that 
> restriction.
>

Patricks's arguement that there is no real difference between a scalar that 
contains a Junction and a scalar that contains a coderef or any type of ref 
when 
it comes to requiring the programmer to know (or test for) what the scalar 
holds, was enough to convince me that no additional pragmas are required for 
junctions. Though I wouldn't object to Damian's c<no autothreading>.

My only problem was that I couldn't see the larger benefit of them. Your 
example 
above is sufficient to convince that being able to encapsulate not just a set 
of 
data, but /required result/ of *any* operations performed using that set data 
did the trick for me. 

I now view the junction

        my $x = any( @values );

as roughly equal to:

        my $junction = bless [ @values ], 'any';

and similarly for the other three. Simplistic, but enough for my mind to make 
the transition.

Using the hyper operators, you would have to re-state the desired result for 
each operation, but with a junction you've encapsulated it in.

> 
> HTH.
> 
> -- Rod Adams
> 

Thanks for taking the time to produce your good example and so carrying me 
along.

njs.

> 
> 
> --------------020209010404060902000407--
Examine what is said, not who speaks. 


Reply via email to