Reply on laptop in wilderness (no network) holydays me void this message by
other messages sent in my absence. Ignore if so.

On 5 Aug 2000 21:40:43 -0000, Perl6 RFC Librarian <[EMAIL PROTECTED]> wrote:
> This and other RFCs are available on the web at
>   http://dev.perl.org/rfc/
> 
> =head1 TITLE
> 
> || should propagate result context to both sides.

Wanted here too.

> =head1 VERSION
> 
>      Maintainer: Peter Scott <[EMAIL PROTECTED]>
>      Date: 5 Aug 2000
>      Version: 1
>      Mailing List: [EMAIL PROTECTED]
>      Number: 45
> 
> =head1 ABSTRACT
> 
> Currently the expression
> 
>      lvalue = expr_A || expr_B
> 
> evaluates C<expr_A> in scalar context, regardless of the type of C<lvalue>, 
> only propagating list or scalar context to C<expr_B>.  This proposal is 
> that the context of C<lvalue> should be propagated to C<expr_A> as well.
> 
> =head1 DESCRIPTION
> 
> It would be nice to be able to say
> 
>      @a = @b || @c
> 
> instead of having to resort to
> 
>      @a = @b ? @b : @c
> 
> The reason that it is not currently possible is that C<@b> (or the list 
> expression in its place) has to be evaluated in scalar context to determine 
> whether to evaluate C<@c>, and that propagating context to C<@b> would 
> require reevaluating it, which might have undesirable side effects (instead 
> of C<@b>, it might be C<decrement_balance()>).

What if for the simple of '@a = @b || @c' either @b or @c is a tied array that
reads the next record as a list out of a database query. Re-evaluating is even
worse, isn't it? The next set of values may have NOTHING to do with the last
set retreived for checking, or it may even be and of scan.

> =head1 IMPLEMENTATION
> 
> It seems that it ought to be possible to evaluate something in a list 
> context and test whether there are any entries in the resulting list 
> without having to reevaluate the expression in a scalar context.  The 
> work-around with the trinary operator also evaluates C<@b> twice.
> 
> There is obviously no need to modify the behavior of the C<&&> operator.

Will this have enough DWIM?

> =head1 REFERENCES
> 
> L<perlop/"C-style Logical Or">

What about Damian's want (RFC 21)

-- 
H.Merijn Brand           Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl5.005.03, 5.6.0 & 516 on HP-UX 10.20, HP-UX 11.00, AIX 4.2, AIX 4.3,
     DEC OSF/1 4.0 and WinNT 4.0 SP-6a,  often with Tk800.022 and/or DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/

Reply via email to