Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Explain type smilies
  • Loading branch information
moritz committed Oct 17, 2015
1 parent ae631ec commit 644d726
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions doc/Language/faq.pod
Expand Up @@ -21,6 +21,31 @@ In this example, the result of the comparison (which is a
L<Junction|/type/Junction>), is
converted to Bool before being printed.
=head2 What are those C<:D> and C<:U> things in signatures?
In Perl 6, classes and other types are objects, and pass type checks
of their own type.
For example if you declare a variable
my Int $x = 42;
then not only can you assign integers (that is, instances of class Int) to it,
but the C<Int> type object itself:
$x = Int
If you want to exclude type objects, you can append the C<:D> type smiley,
which stands for "definite":
my Int:D $x = 42;
$x = Int; # dies with:
# Type check failed in assignment to $x;
# expected Int:D but got Int
Likewise C<:U> constrains to undefined values, that is, type objects.
To explicitly allow either type objects or instances, you can use C<:_>.
=head2 How can I extract the values from a Junction?
Expand Down

0 comments on commit 644d726

Please sign in to comment.