On Sun, Jun 18, 2006 at 05:18:14PM +0200, A. Pagaltzis wrote:
> >  pugs> sub infix:<pv>($x, $cond) { $cond ?? ($x,) !! () }; say 1, 2, (3 pv 
> > 1), 4
> 
> However, what are the evaluation semantics here? Neither the
> ternary nor the `if`-based solutions evaluate the expression they
> return if the condition turns out to be false. Wouldn’t your
> solution evaluate it unconditionally?

That can be solved with an explicit thunk:

sub infix:<pv1> ($x, $cond) { $cond ?? ($x(),) !! () }; say 1, 2, {3} pv 1, 4

Or maybe 'is lazy' on $x?

-- 
Gaal Yahas <[EMAIL PROTECTED]>
http://gaal.livejournal.com/

Reply via email to