Re: Sub args: choose one of two?

2015-07-02 Thread Patrick R. Michaud
On Thu, Jul 02, 2015 at 03:21:11PM -0500, Tom Browder wrote: > Okay, a second look shows me that's not quite as bad as I first though. Another possibility is to let MAIN unpack the args for you, but then check the exclusivity directly instead of using multisubs to do it: sub MAIN(:$need, :$h

Re: Sub args: choose one of two?

2015-07-02 Thread Tom Browder
On Thu, Jul 2, 2015 at 2:59 PM, Patrick R. Michaud wrote: > On Thu, Jul 02, 2015 at 03:22:17PM -0400, Brandon Allbery wrote: >> On Thu, Jul 2, 2015 at 3:08 PM, Tom Browder wrote: >> >> > 1. Write the 'main' program as another subroutine and call it from >> > each of the appropriate multi >> > su

Re: Sub args: choose one of two?

2015-07-02 Thread Tom Browder
On Thu, Jul 2, 2015 at 3:08 PM, yary wrote: > Here's a hackish way to implement #1: ... Ugh, my head hurts, yary, I think I'll save those methods for the future. Thanks! Best, -Tom

Re: Sub args: choose one of two?

2015-07-02 Thread yary
Here's a hackish way to implement #1: #!perl6 proto MAIN (:$need, Str :$hope) { # {*} # If you want to execute the body of the "multi main" stubs, then uncomment this say "I need $need reasons to go on" if $need; say "I have $hope" if $hope; } multi MAIN (Int :$need!) {} multi MAIN (Str :$h

Re: Sub args: choose one of two?

2015-07-02 Thread Patrick R. Michaud
On Thu, Jul 02, 2015 at 03:22:17PM -0400, Brandon Allbery wrote: > On Thu, Jul 2, 2015 at 3:08 PM, Tom Browder wrote: > > > 1. Write the 'main' program as another subroutine and call it from > > each of the appropriate multi > > subs--aarghh! > > > > This seems like the right one to me; it also

Re: Sub args: choose one of two?

2015-07-02 Thread Brandon Allbery
On Thu, Jul 2, 2015 at 3:08 PM, Tom Browder wrote: > 1. Write the 'main' program as another subroutine and call it from > each of the appropriate multi > subs--aarghh! > This seems like the right one to me; it also makes it easier to provide similar functionality as a library. -- brandon s al

Re: Sub args: choose one of two?

2015-07-02 Thread Tom Browder
On Tue, Jun 30, 2015 at 10:25 PM, Patrick R. Michaud wrote: > On Sat, Jun 27, 2015 at 05:39:32PM -0500, Tom Browder wrote: ... > multi sub MAIN(:$need!) { say "need"; } > multi sub MAIN(:$hope!) { say "hope"; } I now have another problem, and I think I know the solution but I hope there i