Skip to content

Commit

Permalink
subset types coerce to Bool
Browse files Browse the repository at this point in the history
  • Loading branch information
TimToady committed Dec 30, 2013
1 parent 7687eca commit 143376c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions S12-objects.pod
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Synopsis 12: Objects

Created: 27 Oct 2004

Last Modified: 28 Dec 2013
Version: 132
Last Modified: 30 Dec 2013
Version: 133

=head1 Overview

Expand Down Expand Up @@ -1617,6 +1617,16 @@ To export a subset type, put the export trait just before the C<where>:

subset Positive of Int is export where * > 0;

Note that the declaration of the C<of> type for a subset doesn't
really mean what an C<of> type means elsewhere in the language. It is
merely declaring the universe of input values for a boolean function.
In fact, when used as a coercion, a subset type returns a C<Bool>
based on its condition, so it can be used directly as a predicate
the overhead of smartmatching:

if Even($x) { ... }
.say if .Even for 1..10;

=head2 Abstract vs Concrete types

For any named type, certain other subset types may automatically be derived
Expand Down

0 comments on commit 143376c

Please sign in to comment.