Skip to content

Commit 0c95459

Browse files
committed
Clarifies why you can't know the type of a native.
Closes #1568 Also some reflow
1 parent 72ca9d3 commit 0c95459

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

doc/Language/functions.pod6

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ called independently of objects.
1313
Subroutines default to lexical (C<my>) scoping, and calls to them are
1414
generally resolved at compile time.
1515
16-
Subroutines can have a L<signature|/type/Signature>, also called I<parameter
17-
list>, which specifies which, if any, arguments the signature expects. It can
18-
specify (or leave open) both the number and types of arguments, and the
19-
return value.
16+
Subroutines can have a L<signature|/type/Signature>, also called
17+
I<parameter list>, which specifies which, if any, arguments the
18+
signature expects. It can specify (or leave open) both the number and
19+
types of arguments, and the return value.
2020
2121
Introspection on subroutines is provided via L<C<Routine>|/type/Routine>.
2222

doc/Language/nativetypes.pod6

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
55
=SUBTITLE Using the types the compiler and hardware make available to you
66
7-
Perl 6 offers a set of I<native> types with a fixed, and known, representation
8-
in memory. This page shows which ones exist and how they can be used. Please
9-
check also the page on L<native numerics|/language/numerics#Native_Numerics> for
10-
more information on them.
7+
Perl 6 offers a set of I<native> types with a fixed, and known,
8+
representation in memory. This page shows which ones exist and how they
9+
can be used. Please check also the page on L<native
10+
numerics|/language/numerics#Native_Numerics> for more information on
11+
them.
1112
1213
X<|int>X<|uint>X<|num>X<|str>
1314
=head1 Types with native representation
1415
15-
Some simple types in Perl 6 have a I<native> representation, indicating that
16-
they will use the C language representation provided by the compiler, operating
17-
system and machine. These are the four native types available:
16+
Some simple types in Perl 6 have a I<native> representation, indicating
17+
that they will use the C language representation provided by the
18+
compiler, operating system and machine. These are the four native types
19+
available:
1820
1921
=begin table
2022
int Equivalent to Int
@@ -28,26 +30,29 @@ L<NativeCall|/language/nativecall> interface (e.g., Perl 6's C<int> can be 8
2830
bytes but C's C<int> is only 4 bytes). Instead, the types below will have to be
2931
used instead of the types C<int> or C<num> listed above.
3032
31-
In general, these variables will behave in the same way as regular scalar
32-
variables, in a behavior that is called
33-
L<I<auto-boxing>|/language/numerics#Auto-Boxing>; however, there are some
34-
differences, since what you are actually declaring is how they will be
35-
represented, not their actual type. The first one is that their type will be
36-
actually their equivalent type, not their native type.
33+
In general, these variables will behave in the same way as regular
34+
scalar variables, in a behavior that is called
35+
L<I<auto-boxing>|/language/numerics#Auto-Boxing>; however, there are
36+
some differences, since what you are actually declaring is how they will
37+
be represented, not their actual type. The first one is that their type
38+
will be actually their equivalent type, not their native type.
3739
3840
my int $intillo = 3;
3941
say $intillo.^name; # OUTPUT: «Int␤»
4042
41-
This obviously means that they will smartmatch their equivalent, not their
42-
native type:
43+
This obviously means that they will smartmatch their equivalent, not
44+
their native type:
4345
4446
my str $strillo = "tres";
4547
say $strillo ~~ str; # OUTPUT: «False␤»
4648
say $strillo ~~ Str; # OUTPUT: «True␤»
4749
48-
They cannot be bound either. Trying to do C<my num $numillo := 3.5> will raise
49-
the exception C<Cannot bind to natively typed variable '$variable-name'; use
50-
assignment instead>.
50+
This is due to the fact that Natives don't know their types because
51+
they're just values, without any meta-data.
52+
53+
They cannot be bound either. Trying to do C<my num $numillo := 3.5> will
54+
raise the exception C<Cannot bind to natively typed variable
55+
'$variable-name'; use assignment instead>.
5156
5257
X<|int8>X<|int16>X<|int32>X<|int64>X<|uint8>X<|uint16>X<|uint32>X<|uint64>X<|num32>X<|num64>X<|byte>
5358
=head1 Types with native representation and size

0 commit comments

Comments
 (0)