Skip to content

Commit f1ac9f5

Browse files
committed
revert the .truth conjecture
Shouldn't have speculated about .truth along with the .gist change, so reverting that part. Also, what conditionals do to break the boolean circularity is left up to the implementation.
1 parent d3f2a14 commit f1ac9f5

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

S02-bits.pod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4483,22 +4483,22 @@ containers (such as slice and hash context; see S03 for details).
44834483
=item *
44844484

44854485
Unlike in Perl 5, objects are no longer always considered true.
4486-
It depends on the state of their C<.truth> method, which may either be
4486+
It depends on the state of their C<.Bool> method, which may either be
44874487
a synthetic attribute or an explicitly represented bit in the object. Classes get to decide
44884488
which of their values are true and which are false. Individual objects
44894489
can override the class definition:
44904490

44914491
return 0 but True;
44924492

4493-
This overrides the C<.truth> method of the C<0> without changing its
4493+
This overrides the C<.Bool> method of the C<0> without changing its
44944494
official type (by mixing the method into an anonymous derived type).
44954495

44964496
=item *
44974497

4498-
The definition of C<.truth> for the most ancestral type (that is, the
4498+
The definition of C<.Bool> for the most ancestral type (that is, the
44994499
C<Mu> type) is equivalent to C<.defined>. Since type objects are
45004500
considered undefined, all type objects (including C<Mu> itself)
4501-
are false unless the type overrides the definition of C<.truth>
4501+
are false unless the type overrides the definition of C<.Bool>
45024502
to include undefined values. Instantiated objects default to true
45034503
unless the class overrides the definition. Note that if you could
45044504
instantiate a C<Mu> it would be considered defined, and thus true.

S03-operators.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3807,8 +3807,8 @@ because it will always choose the C<True> case. Instead use something like
38073807
a conditional context uses internally:
38083808

38093809
given $boolean {
3810-
when .truth == 1 {...}
3811-
when .truth == 0 {...}
3810+
when .Bool == 1 {...}
3811+
when .Bool == 0 {...}
38123812
}
38133813

38143814
Better, just use an C<if> statement. In any case, if you try to smartmatch

S04-control.pod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ Whenever a new exception is stored in C<$!>, it becomes the new main
12191219
exception, and if the old main exception is not marked as handled,
12201220
it is pushed onto the internal list of unhandled exceptions.
12211221

1222-
If you test a C<Failure> for C<.defined> or C<.truth>, it causes C<$!>
1222+
If you test a C<Failure> for C<.defined> or C<.Bool>, it causes C<$!>
12231223
to mark the main exception as I<handled>; the exception acts as a
12241224
relatively harmless undefined value thereafter. Any other use of the
12251225
C<Failure> object to extract a normal value will throw its associated

S12-objects.pod

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,28 +1962,29 @@ roles, and the enum values are really subset types of C<Int>, though the
19621962
constant objects themselves know that they are of type C<Bool> or C<Taint>,
19631963
and can therefore be used correctly in multimethod dispatch.
19641964

1965-
You can call the low-level C<.truth> coercion on any built-in type, because
1966-
all built-in types do the C<Boolean> role, which requires a C<.truth> method.
1965+
You can call the low-level C<.Bool> coercion on any built-in type, because
1966+
all built-in types do the C<Boolean> role, which requires a C<.Bool> method.
19671967
Hence, there is a great difference between saying
19681968

19691969
$x does Boolean; # a no-op, since $x already does Boolean
19701970
$x does Bool; # create a $.Bool attribute, also does Boolean
19711971

19721972
Conditionals evaluate the truth of a boolean expression by testing
1973-
the return value of C<.truth> like this:
1974-
1975-
$obj.truth != 0
1973+
the return value of C<.Bool>; how they do this is a mystery, except
1974+
that they must do something mysterious and platform dependent to
1975+
avoid calling C<.Bool> recursively on the results of C<.Bool>.
19761976

19771977
Never compare a value to "C<True>". Just use it
19781978
in a boolean context. Well, almost never...
19791979

19801980
If you wish to be explicit about a boolean context, use the high-level
19811981
C<so> function or C<?> prefix operator, which are underlying based
1982-
on the C<.truth> method. Also, use these high level functions when you wish
1983-
to autothread junctions, since C<.truth> forces collapse of a junction's
1984-
wavefunction. (Similarly, C<.gist> forces stringification of the entire
1985-
junction, while prefix:<~> does not.) The C<.Bool> coercion also autothreads
1986-
rather than collapsing.
1982+
on the C<.Bool> method. Since C<.Bool> always collapses junctions,
1983+
so do these functions. (Hence if you really need to autothread a
1984+
bunch of boolean values, you'll have to convert them to some other
1985+
type such as C<Bit> that can be used as a boolean value later.
1986+
Generally it makes no sense to autothread booleans, so we have a
1987+
policy of collapsing them sooner rather than later.)
19871988

19881989
Like other type names and constant names, enum keynames are parsed as
19891990
standalone tokens representing scalar values, and don't look for any

S32-setting-library/Basics.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ declared.
9090

9191
XXX Copied from S02 -- should it be deleted from there?
9292

93-
The definition of C<.truth> for the most ancestral type (that is, the
93+
The definition of C<.Bool> for the most ancestral type (that is, the
9494
C<Mu> type) is equivalent to C<.defined>. Since type objects are
9595
considered undefined, all type objects (including C<Mu> itself)
96-
are false unless the type overrides the definition of C<.truth>
96+
are false unless the type overrides the definition of C<.Bool>
9797
to include undefined values. Instantiated objects default to true
9898
unless the class overrides the definition. Note that if you could
9999
instantiate a C<Mu> it would be considered defined, and thus true.

0 commit comments

Comments
 (0)