Author: lwall Date: 2010-05-26 19:21:03 +0200 (Wed, 26 May 2010) New Revision: 30812
Modified: docs/Perl6/Spec/S03-operators.pod Log: [S03] explain how not-raising works on != and ne Modified: docs/Perl6/Spec/S03-operators.pod =================================================================== --- docs/Perl6/Spec/S03-operators.pod 2010-05-26 16:55:57 UTC (rev 30811) +++ docs/Perl6/Spec/S03-operators.pod 2010-05-26 17:21:03 UTC (rev 30812) @@ -15,8 +15,8 @@ Created: 8 Mar 2004 - Last Modified: 21 May 2010 - Version: 205 + Last Modified: 26 May 2010 + Version: 206 =head1 Overview @@ -3118,22 +3118,29 @@ successful thread may terminate the other threads abruptly. In general you probably want to avoid code with side effects in junctions. -Use of negative operators with syntactically recognizable junctions may -produce a warning on code that works differently in English than in Perl. -Instead of writing +Use of negative operators with junctions is potentially problematic if +auththreaded naively. However, by defining C<!=> and C<ne> in terms +of the negation metaoperator, we automatically get the "not raising" +that is expected by an English speaker. That is if $a != 1 | 2 | 3 {...} -you need to write +really means - if not $a == 1 | 2 | 3 {...} + if $a ![==] 1 | 2 | 3 {...} -However, this is only a syntactic warning, and +which the metaoperator rewrites to a higher-order function resembling +something like: - if $a != $b {...} + negate((* == *), $a, (1|2|3)); -will not complain if $b happens to contain a junction at runtime. +which ends up being equivalent to: + if not $a == 1 | 2 | 3 {...} + +which is the semantics an English speaker expects. However, it may well +be better style to write the latter form yourself. + Junctive methods on arrays, lists, and sets work just like the corresponding list operators. However, junctive methods on a hash make a junction of only the hash's keys. Use the listop form (or an