> Date: Mon, 20 Jan 2003 09:20:45 -0800 (PST)
> From: Austin Hastings <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
>
>
> --- Luke Palmer <[EMAIL PROTECTED]> wrote:
> > > Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
> > > Date: Sat, 18 Jan 2003 15:07:56 -0800 (PST)
> > > From: "Sean O'Rourke" <[EMAIL PROTECTED]>
> > > Cc: Damian Conway <[EMAIL PROTECTED]>,
> > > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > X-SMTPD: qpsmtpd/0.20, http://develooper.com/code/qpsmtpd/
> > >
> > > On Sat, 18 Jan 2003, Michael Lazzaro wrote:
> > > > So 'if' and friends are just (native) subroutines with prototypes
> > like:
> > > >
> > > > sub if (bool $c, Code $if_block) {...};
> > >
> > > IIRC it's not that pretty, unfortunately, if you want to support
> > this:
> > >
> > > if $test1 {
> > > # blah
> > > } elsunless $test2 {
> > > # ...
> > > }
> >
> > Ahh, you used the unmentionable _correctly_, unlike so many who
> > misunderstood some six months ago.
> >
> > > since that gets parsed as
> > >
> > > if($test1, { ... }) # aiee: too many arguments to "if"
> >
> > That is not a problem:
> >
> > # We'll just pretend that dereferencing the "undef" sub does
> > nothing
> >
> > sub if ($test, █ &follow) {
> > # ... er, how do you write "if"? Hmm...
> > $test ?? block() :: follow()
> > }
> >
> > sub elsunless ($test, █ &follow) {
> > !$test ?? block() :: follow()
> > }
> >
> > So:
> >
> > if $test1 {
> > # stuff
> > }
> > elsunless $test2 {
> > # stuff 2
> > }
> >
> > Becomes (semantically):
> >
> > if($test1, {
> > # stuff
> > }, elsunless($test2, {
> > # stuff 2
> > }));
>
> Is this magic, or do coderef args construct closures, or what? How do
> you avoid evaluating the argument to elsunless() when feeding it to the
> if() sub?
Oops. Good point. In this case I see no way of doing it except for
specifying magic:
sub elsunless ($test is lazy, █ &follow) {
!$test ?? block() :: follow()
}
Or something like that. Darn.
Luke