Patrick R. Michaud wrote:
On Mon, Dec 03, 2007 at 12:20:02PM +0000, Smylers wrote:
cdumont writes:
I don't really think using the column in a ternary means that you
cannot use it else where.
We started off with that, and it was changed specifically because it was
causing a problem; I can't remember exactly what, but it's in this
list's archives somewhere.
Remember that whatever expression you want to use the colon for is going
to be valid between the ? and : parts of the ? ... : operator, and so
you need to avoid the colon being confused for the : which marks the end
of this part of the ? ... : operator.
...and it's not just the colon, but the ? also has the potential to be
confusing here, because there's a prefix:<?> operator that is used to
coerce into boolean context.
Which indirectly gets around to an even stronger reason for using
C<?? !!> over C<? :> -- Perl 6 aims for a consistency in the
use of the ? and ! characters to mean "boolean true" and "boolean
not true". This is true not only for the operators, but also in
regular expressions and other places. So, having something like
$foo = $cond ?? ...if_true... !! ...if_not_true... ;
achieves several important goals:
- it frees up the ? and : characters for other purposes
- it reinforces the convention of ? as "if true" and ! as "if false"
- it is more visually distinctive, so that the ternary tokens don't
get lost in the middle of other operands and expressions
- it simplifies parsing (both compiler and human) and improves
error reporting
In my case, I've found the switch to ?? !! to be fairly
natural, and that I don't use it often enough to worry about
the extra characters.
OK that explains the logic behind the conclusion. Thank you!
I don't use it that much either but it was for the sake of coherence
with other languages
but Mr. Wall got the point in his response!
--
シリル・デュモン(Cyrille Dumont)
[EMAIL PROTECTED]
our work is the portrait of ourselves
tel: 03-5690-0230 fax: 03-5690-7366
http://www.comquest.co.j