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. > > As for the functions, i didn't see that much for hashes and arrays > > which was a big disappointment. > > What were you hoping for? Many things which were functions in Perl 5 > are now also available as methods in Perl 6. If you post here with what > you're disappointed to be missing, it may be that somebody can reply > pointing out where the equivalent functionality is! As noted at the beginning of Synopsis 1: Another assumption has been that if we don't talk about something in these Synopses, it's the same as it is in Perl 5. Pm