Revision 27106
- Date:
- 2009/06/17 19:08:15
- Files:
Legend:
- Added
- Removed
- Modified
-
docs/Perl6/Spec/S02-bits.pod
12 12 13 13 Maintainer: Larry Wall <larry@wall.org> 14 14 Date: 10 Aug 2004 15 Last Modified: 2 Jun 2009 16 Version: 170 15 Last Modified: 17 Jun 2009 16 Version: 171 17 17 18 18 This document summarizes Apocalypse 2, which covers small-scale 19 19 lexical items and typological issues. (These Synopses also contain … … 464 464 name" of the resulting type, so one C<Array of Int> is equivalent to 465 465 another C<Array of Int>. (Another way to look at it is that the type 466 466 instantiation "factory" is memoized.) Typename aliases are considered 467 equivalent to the original type. 467 equivalent to the original type. In particular, the C<Array of Int> syntax 468 is just sugar for C<Array:of(Int)>, which is the canonical form of an 469 instantiated generic type. 468 470 469 471 This name equivalence of parametric types extends only to parameters 470 472 that can be considered immutable (or that at least can have an … … 800 802 801 803 =item * 802 804 805 The C<utf8> type is derived from C<buf8>, with the additional constraint 806 that it may only contain validly encoded UTF-8. Likewise, C<utf16> is 807 derived from C<buf16>, and C<utf32> from C<buf32>. 808 809 Note that since these are type names, parentheses must always be 810 used to call them as coercers, since the listop form is not allowed 811 for coercions. That is: 812 813 utf8 op $x 814 815 is always parsed as 816 817 (utf8) op $x 818 819 and never as 820 821 utf8(op $x) 822 823 =item * 824 803 825 The C<*> character as a standalone term captures the notion of 804 826 "Whatever", which is applied lazily by whatever operator it is an 805 827 argument to. Generally it can just be thought of as a "glob" that … … 1163 1185 1164 1186 actually means: 1165 1187 1166 my Hash[Array[Recipe]] %book; 1188 my Hash:of(Array:of(Recipe)) %book; 1167 1189 1168 1190 Because the actual variable can be hard to find when complex types are 1169 1191 specified, there is a postfix form as well: … … 1215 1237 my Cat|Dog Fish $mitsy = new Fish but { Bool.pick ?? .does Cat 1216 1238 !! .does Dog }; 1217 1239 1240 [Note: the above is a slight lie, insofar as parameters are currently 1241 restricted for 6.0.0 to having only a single main type for the 1242 formal variable until we understand MMD a bit better.] 1243 1218 1244 =head2 Parameter types 1219 1245 1220 1246 Parameters may be given types, just like any other variable: