Re: Short-circuiting user-defined operators

2003-04-05 Thread Larry Wall
On Tue, Apr 01, 2003 at 08:26:38PM -0500, Joe Gottman wrote: :Is there any way to write a user-defined operator so that it : short-circuits, like && and || ? This might be function trait, for : instance, : : sub infix:!! ($lhs, $rhs) is short_circuit {...} Honestly, you guys. You make thi

Re: Short-circuiting user-defined operators

2003-04-03 Thread Dave Whipp
Joe Gottman wrote: There are two reasonable semantics for deferred parameters: 1) lazy evaluation with caching, where the evaluation of the actual expression in the call is deferred until the sub actauly makes use of it and the result is then cached and reused as necessary. Any side effects happ

Re: Short-circuiting user-defined operators

2003-04-03 Thread Joe Gottman
- Original Message - From: "Luke Palmer" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, April 03, 2003 6:39 PM Subject: Re: Short-circuiting user-defined operators > > Paul wrote: > > > --- Austin Hastings

Re: Short-circuiting user-defined operators

2003-04-03 Thread Austin Hastings
--- Luke Palmer <[EMAIL PROTECTED]> wrote: > > Paul wrote: > > > --- Austin Hastings <[EMAIL PROTECTED]> wrote: > > > > > >>Dave Whipp wrote: > > >> > > >>>Joe Gottman wrote: > > > > > > > > > Getting deep -- sorry. :) > > > > > > > > Alternatively, there might be a new parameter type tha

Re: Short-circuiting user-defined operators

2003-04-03 Thread Luke Palmer
> Paul wrote: > > --- Austin Hastings <[EMAIL PROTECTED]> wrote: > > > >>Dave Whipp wrote: > >> > >>>Joe Gottman wrote: > > > > > > Getting deep -- sorry. :) > > > > > Alternatively, there might be a new parameter type that indicates > that the parameter is not evaluated immediately: >

Re: Short-circuiting user-defined operators

2003-04-03 Thread Paul
--- Austin Hastings <[EMAIL PROTECTED]> wrote: > --- Paul <[EMAIL PROTECTED]> wrote: > > > But what to do about matrix arithmetic and other simple > > > threadable tasks? > > > sub m_add(@a, @b) { my @result; my $i, $j; @result = @a; > > > for @result -> $i {:is threaded # Thread this block

Re: Short-circuiting user-defined operators

2003-04-03 Thread Austin Hastings
--- Paul <[EMAIL PROTECTED]> wrote: > > But what to do about matrix arithmetic and other simple threadable > > tasks? > > > > sub m_add(@a, @b) { > > my @result; > > my $i, $j; > > @result = @a; > > for @result -> $i {:is threaded # Thread this block? > > for @result[$i]; @b -> $j;

Re: Short-circuiting user-defined operators

2003-04-03 Thread Mark Biggar
Paul wrote: --- Austin Hastings <[EMAIL PROTECTED]> wrote: Dave Whipp wrote: Joe Gottman wrote: Getting deep -- sorry. :) Alternatively, there might be a new parameter type that indicates that the parameter is not evaluated immediately: sub infix:!! ($lsh, $rhs is deferred) {...} If the sta

Re: Short-circuiting user-defined operators

2003-04-03 Thread Paul
--- Austin Hastings <[EMAIL PROTECTED]> wrote: > Dave Whipp wrote: > > Joe Gottman wrote: Getting deep -- sorry. :) > > > Alternatively, there might be a new parameter type that indicates > > > that the parameter is not evaluated immediately: > > > > > > sub infix:!! ($lsh, $rhs is deferred) {.

Re: Short-circuiting user-defined operators

2003-04-03 Thread Austin Hastings
Dave Whipp wrote: > Joe Gottman wrote: > > > Alternatively, there might be a new parameter type that indicates > > that the parameter is not evaluated immediately: > > > > sub infix:!! ($lsh, $rhs is deferred) {...} > A nice concept! So nice, in fact, that it would be a shame to limit > it to

Re: Short-circuiting user-defined operators

2003-04-02 Thread Matthijs van Duin
Is there any specific reason this was a reply to Michael Lazarro's "Re: == vs. eq" dated Tue, 1 Apr 2003 16:30:00 -0800 ? (What I mean is, PLEASE don't use reply when you're not replying at all) -- Matthijs van Duin -- May the Forth be with you!

Re: Short-circuiting user-defined operators

2003-04-01 Thread Luke Palmer
Dave Whipp writes: > Another, very different, situation where laziness is good is to abstract > fork/join situations: > > >my $a is lazy_thread := expensive_fn1(...); >my $b is lazy_thread := expensive_fn2(...); > >print $a + $b; > > In this scenario, each expensive evaluation woul

Re: Short-circuiting user-defined operators

2003-04-01 Thread Dave Whipp
Joe Gottman wrote: Alternatively, there might be a new parameter type that indicates that the parameter is not evaluated immediately: sub infix:!! ($lsh, $rhs is deferred) {...} A nice concept! So nice, in fact, that it would be a shame to limit it to function args. I could see myself writing:

Short-circuiting user-defined operators

2003-04-01 Thread Joe Gottman
Is there any way to write a user-defined operator so that it short-circuits, like && and || ? This might be function trait, for instance, sub infix:!! ($lhs, $rhs) is short_circuit {...} Alternatively, there might be a new parameter type that indicates that the parameter is not evaluated im