Skip to content

Commit 7a7f642

Browse files
committed
Align Mu.so & Mu.not docs with design
The previous explanation of so() (double-negation) wasn't consistent with implementation or mentioned in design docs. It's a common JavaScript idiom but not relevant to Perl 6. This aligns with the docs for prefix:<so> and :<not>, too. Ref #2693.
1 parent 86ab3c5 commit 7a7f642

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

doc/Type/Mu.pod6

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,10 @@ Returns the given item to the enclosing C<gather> block, without introducing a n
609609
610610
method so()
611611
612-
Returns a C<Bool> value representing the result of negating (with implicit
613-
conversion to C<Bool>) the expression and then again computing the negation of
614-
the result, thus computing the C<Bool> equivalent to the original expression.
612+
Evaluates the item in boolean context (and thus collapses Junctions),
613+
and returns the result.
614+
It is the opposite of C<not>, and equivalent to the
615+
L«C<?> operator|/language/operators#prefix_?».
615616
616617
One can use this method similarly to the English sentence: "If that is B<so>,
617618
then do this thing". For instance,
@@ -622,27 +623,24 @@ then do this thing". For instance,
622623
say "Verbose option detected in arguments";
623624
} # OUTPUT: «Verbose option detected in arguments␤»
624625
625-
The C<$verbose-selected> variable in this case contains a
626-
L<C<Junction>|/type/Junction>, whose value is C<any(any(False, False),
627-
any(False, False), any(False, False), any(True, False))>. That is actually a
628-
I<truish> value; thus, negating it will yield C<False>. The negation of that
629-
result will be C<True>. C<so> is performing all those operations under the hood.
630-
631626
=head2 method not
632627
633628
method not()
634629
635-
Returns a C<Bool> value representing the logical negation of an expression.
636-
Thus it is the opposite of C<so>.
630+
Evaluates the item in boolean context (and thus collapses Junctions),
631+
and negates the result.
632+
It is the opposite of C<so>, and equivalent to the
633+
L«C<!> operator|/language/operators#prefix_!».
637634
638635
my @args = <-a -e -b>;
639636
my $verbose-selected = any(@args) eq '-v' | '-V';
640637
if $verbose-selected.not {
641638
say "Verbose option not present in arguments";
642639
} # OUTPUT: «Verbose option not present in arguments␤»
643640
644-
Since there is also a prefix version of C<not>, the above code reads better
645-
like so:
641+
Since there is also a
642+
L«prefix version of C<not>|/language/operators#prefix_not»,
643+
this example reads better as:
646644
647645
my @args = <-a -e -b>;
648646
my $verbose-selected = any(@args) eq '-v' | '-V';

0 commit comments

Comments
 (0)