> Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
> Date: Mon, 18 Nov 2002 18:59:58 -0500
> From: matt diephouse <[EMAIL PROTECTED]>
> X-SMTPD: qpsmtpd/0.12, http://develooper.com/code/qpsmtpd/
> 
> Damian Conway wrote:
>
>> matt diephouse wrote:
> >
> >>>     $junction = $x | $y | $z;
> >>>     foo($junction);            # Call foo($x), foo($y), and foo($z)
> >>>                                # in parallel and collect the results
> >>>                                    # in a disjunction
> >>
> >>
> >>
> >> Looking at that code, I'm wondering how you pass a junction. Suppose 
> >> I want to pass a junction to a subroutine instead of calling the sub 
> >> with each value of the junction... how would I do that?
> >
> >
> > Tell the sub that it's expecting an undistributed junction as its 
> > argument:
> >
> >     sub foo($param is junction) {...}
> >
> > Damian
> 
> Doesn't that go against perl's dynamic philosophy? That requires me to 
> type my methods where I may not want to. Let's say I have a sub that 
> logs errors:
>  
>     sub log_error($fh, $error) { # filehandle and error msg
>         $error_num++; # global
>         print $fh: "$error_num: $error\n";
>     }
>    
>     my $file = open "error.log";
>     log_error $file, "This message is phony";
> 
> However, during my debugging, I realize that I need two error logs 
> (Don't ask me why, I just do). Instead of changing the one line to
> 
>     my $file = open "error.log" & "../some/other.log"; # I hope this is 
> legal
> 
> I also need to change the subroutine now, because the error count will 
> be off, even though my change is temporary. It reduces the ability to 
> write subs that accept anything and DWIM. The question is when/how do 
> you choose whether to pass a junction or evaluate all of them. I think 
> that the solution would be best left out of the sub's signature though. 
> Of course this has to stop somewhere; you eventually have to pick a state.

It's either that or have your functions, which were perfectly logical
suddenly be subject to junction logic.  That is, if $x == 2  and  $x
== 3 both being true, when your code relies on them not both firing.
I think it's a very good decision to make sure that functions know
they might be getting junctions and making it explicit.   

Luke

>     m:att d:iephouse
> 
> 

Reply via email to