Re: Ternary operator
- From: chas.owens@xxxxxxxxx (Chas. Owens)
- Date: Fri, 11 Sep 2009 15:10:08 -0400
On Fri, Sep 11, 2009 at 14:54, Chas. Owens <chas.owens@xxxxxxxxx> wrote:
snip
snipIn case it isn't clear enough, my question (not directly to you, butsnip
to the perl maintainers) is "Where does perl document the ternary
operator's behaviour of only evaluating either the second or the third
argument, never both?" I have looked in perldoc perlop. If you have a
better place for me to look, by all means let me know. But if it's not
in perlop, why isn't it?
It is fully documented in the source code of Perl; as many things are.
It is not documented the way you want in perlop because most people
understand the way it is currently documented there.
Apparently it is also documented, to the level of detail I think you
require, in the 3rd edition of the Camel:
As in C, ?: is the only trinary operator. It's often called the
conditional operator because it works much like an if-then-else,
except that, since it's an expression and not a statement, it can be
safely embedded within other expressions and functions calls. As a
trinary operator, its two parts separate three expressions:
COND ? THEN : ELSE
If the condition COND is true, only the THEN expression is evaluated,
and the value of that expression becomes the value of the entire
expression. Otherwise, oly the ELSE expression is evaluated, and its
value becomes the value of the entire expression.
Scalar or list context propagates downward into the second or third
argument, whichever is selected. (The first argument is always in
scalar context, since it is a conditional.)
More follows, but you get the idea.
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
.
- References:
- Re: Ternary operator
- From: Uri Guttman
- Re: Ternary operator
- From: Philip Potter
- Re: Ternary operator
- From: John W. Krahn
- Re: Ternary operator
- From: Philip Potter
- Re: Ternary operator
- From: John W. Krahn
- Re: Ternary operator
- From: John W. Krahn
- Re: Ternary operator
- From: Philip Potter
- Re: Ternary operator
- From: Chas. Owens
- Re: Ternary operator
- Prev by Date: Re: Ternary operator
- Next by Date: Re: Ternary operator
- Previous by thread: Re: Ternary operator
- Next by thread: Re: Ternary operator
- Index(es):
Relevant Pages
|