develooper Front page | perl.perl5.porters | Postings from November 2009

RE: "If" your subscript goes bump in the night

Thread Previous | Thread Next
From:
Jan Dubois
Date:
November 2, 2009 18:00
Subject:
RE: "If" your subscript goes bump in the night
Message ID:
022701ca5c29$5def9f80$19cede80$@com
On Mon, 02 Nov 2009, Ben Morrow wrote:
> Is there any point going over all this again? Removing 'err' was
> considered to be a Rule 1 decision, so unless that changes we're not
> doing anything but stirring up old muck.

The decision was not just to remove "err", but also to add "andthen"
and "orelse" with slightly different semantics.  Rafael wrote:

| Larry decided to rename err to orelse in Perl 6. (with a few changes,
| irrelevant to Perl 5, see the perl6-language mailing list.) Also, a
| new operator andthen has been added. See synopsis 3.
|
| That makes err obsolete. So, I'll remove it from Perl 5.10.
|
| orelse and andthen can wait a further release to be added (as a
| feature in the sense of feature.pm) to Perl 5.

http://www.nntp.perl.org/group/perl.perl5.porters/2007/09/msg128324.html

So we could revive "dor" as "orelse".  The question is, would we also
have to implement the assignment to $! as well?

|    test1() orelse test2() orelse test3() ...
|
| Returns the first argument that evaluates successfully (that is,
| if the result is defined).  Otherwise returns the result of the
| right argument.
|
| If the right side is a block or pointy block, the result of the left
| side is bound to any arguments of the block.  If the right side is
| not a block, a block scope is assumed around the right side, and the
| result of the left side is implicitly bound to C<$!> for the scope
| of the right side.

http://svn.pugscode.org/pugs/docs/Perl6/Spec/S03-operators.pod

I have to admit that I don't actually understand the spec though:
the right side would only be evaluated when the left side is undef,
so wouldn't $! always be set to undef (and therefore 0)?

Cheers,
-Jan


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About