Skip to content

Commit 47d87c2

Browse files
committed
Clarification about identity and scalars
Also goes towards #114
1 parent 7776882 commit 47d87c2

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

doc/Language/structures.pod6

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,30 @@ can still access its internal structure.
3030
3131
(1,2,3, $(4,5))[3][0].say; # OUTPUT: «4␤»
3232
33+
An interesting side effect, or maybe intended feature, is that scalarization
34+
conserves identity of complex structures.
35+
36+
for ^2 {
37+
my @list =(1,1);
38+
say @list.WHICH;
39+
} # OUTPUT: «Array|93947995146096␤Array|93947995700032␤»
40+
41+
Every time C<(1,1)> is assigned, the variable created is going to be different
42+
in the sense that C<===> will say it is; as it is shown, different values of the
43+
internal pointer representation are printed. However
44+
45+
for ^2 {
46+
my $list =(1,1);
47+
say $list.WHICH
48+
} # OUTPUT: «List|94674814008432␤List|94674814008432␤»
49+
50+
In this case, C<$list> is using the Scalar sigil and thus will be an C<Scalar>. Any scalar will the same value will be exactly the same, as shown when printing the pointers.
3351
3452
=head1 Complex data structures
3553
36-
TBD
54+
Complex data structures fall in two different broad categories L<Positional|/type/Positional>, or list-like and L<Associative|/type/Associative>, or key-value pair like, according to how you access its first-level elements. In general, complex data structures, including objects, will be a combination of both, with object properties assimilated to key-value pairs.
55+
56+
3757
3858
=head1 Functional structures
3959

0 commit comments

Comments
 (0)