diff6-10.chapter6.txtこのページは最後に更新されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。 last mod. 2008-11-01 (土) 10:51:56
4a5 > 18a20 > 44a47 > 52a56 > 56c60,61 < ident ::= (letter|_) { letter|0...9|_|' } --- > ident ::= (letter| _) { letter| 0...9| _| ' } > 62,65c67,71 < current implementation (except on MacOS) also recognizes as letters all < accented characters from the ISO 8859-1 (``ISO Latin 1'') set. All characters < in an identifier are meaningful. The current implementation places no limits on < the number of characters of an identifier. --- > current implementation also recognizes as letters all accented characters from > the ISO 8859-1 ("ISO Latin 1") set. All characters in an identifier are > meaningful. The current implementation accepts identifiers up to 16000000 > characters in length. > 70,85c76,83 < [+] < --- < integer-literal ::= [-] { 0...9 }[ ] < --- < [+] < --- < | [-] (0x|0X) { 0...9|A...F|a...f }[ ] < --- < [+] < --- < | [-] (0o|0O) { 0...7 }[ ] < --- < [+] < --- < | [-] (0b|0B) { 0...1 }[ ] < --- --- > integer-literal ::= [-] (0...9) { 0...9| _ } > > | [-] (0x| 0X) (0...9| A...F| a...f) { 0...9| A...F| > a...f| _ } > | [-] (0o| 0O) (0...7) { 0...7| _ } > > | [-] (0b| 0B) (0...1) { 0...1| _ } > 91,97c89,95 < ------------------------------- < |Prefix| Radix | < ------------------------------- < |0x, 0X|hexadecimal (radix 16)| < |0o, 0O|octal (radix 8) | < |0b, 0B|binary (radix 2) | < ------------------------------- --- > -------------------------------- > |Prefix | Radix | > -------------------------------- > | 0x, 0X|hexadecimal (radix 16)| > |0o, 0O |octal (radix 8) | > |0b, 0B |binary (radix 2) | > -------------------------------- 100a99,101 > For convenience and readability, underscore characters (_) are accepted (and > ignored) within integer literals. > 105,112c106,107 < [+] [+] < < --- --- < < float-literal ::= [-] { 0...9 }[ ] [. { 0...9 }] [(e|E) [+|-] { 0...9 }[ < ]] < --- --- < --- > float-literal ::= [-] (0...9) { 0...9| _ } [. { 0...9| _ }] [(e| E) [+| -] > (0...9) { 0...9| _ }] 121a117,119 > For convenience and readability, underscore characters (_) are accepted (and > ignored) within floating-point literals. > 127a126 > 129a129 > | \x (0...9| A...F| a...f) (0...9| A...F| a...f) 135c135 < ------------------------------------------------------- --- > ---------------------------------------------------------- 137,138c137,138 < ------------------------------------------------------- < |\\ |backslash (\) | --- > ---------------------------------------------------------- > | \\ |backslash (\) | 145,146c145,149 < |\ddd |the character with ASCII code ddd in decimal| < ------------------------------------------------------- --- > |\space |space (SPC) | > |\ddd |the character with ASCII code ddd in decimal | > |\xhh |the character with ASCII code hh in hexadecimal| > ---------------------------------------------------------- > 152a156 > 164a169 > 171,172c176,178 < label ::= ~ (a ... z) { letter|0...9|_|' } : < optlabel ::= ? (a ... z) { letter|0...9|_|' } : --- > label ::= ~ (a ... z| _) { letter| 0...9| _| ' } : > > optlabel ::= ? (a ... z| _) { letter| 0...9| _| ' } : 177a184 > 181,182c188,191 < infix-symbol ::= (= | < | > | @ | ^ | | | & | + | - | * | / | $ | %) { < operator-char } --- > infix-symbol ::= (= | < | > | @ | ^ | | | & | + | - | * | / | $ > | %) { operator-char } > > 185,186d193 < operator-char ::= ! | $ | % | & | * | + | - | . | / | : | < | = | > | ? | < @ | ^ | | | ~ 188c195,201 < Sequences of ``operator characters'', such as <=> or !!, are read as a single --- > > operator-char ::= ! | $ | % | & | * | + | - | . | / | : | < | = | > > | ? | @ | ^ | | | ~ > > > > Sequences of "operator characters", such as <=> or !!, are read as a single 192a206 > 198,202c212,215 < << < and as assert asr begin class < closed constraint do done downto else < end exception external false for fun < function functor if in include inherit --- > << and as assert asr begin class > constraint do done downto else end > exception external false for fun function > functor if in include inherit initializer 205c218 < new of open or parser private --- > new object of open or private 211,215c224,227 < << < # & ' ( ) * , -> ? < ?? . .. .( .[ : :: := ; < ;; <- = [ [| [< {< ] |] < >] >} _ ` { | } ~ --- > << != # & && ' ( ) * + , - > -. -> . .. : :: := :> ; ;; < > <- = > >] >} ? ?? [ [< [> [| > ] _ ` { {< | |] } ~ 216a229,233 > Note that the following identifiers are keywords of the Camlp4 extensions and > should be avoided for compatibility reasons. > << parser << <: >> $ $$ $: > >> > 222,225c239,242 < Lexical ambiguities are resolved according to the ``longest match'' rule: < when a character sequence can be decomposed into two tokens in several < different ways, the decomposition retained is the one with the longest first < token. --- > Lexical ambiguities are resolved according to the "longest match" rule: when > a character sequence can be decomposed into two tokens in several different > ways, the decomposition retained is the one with the longest first token. > 230,237c247,251 < [+] < --- < linenum-directive ::= # {0 ... 9}[ ] < --- < [+] < --- < | # {0 ... 9}[ ] " { string-character } " < --- --- > + > linenum-directive ::= # {0 ... 9} > + > | # {0 ... 9} " { string-character } " > 247a262 > 259a275 > 267a284 > 275a293 > 283a302 > 288c307,308 < supports strings containing up to 2^24 - 6 characters (16777210 characters). --- > supports strings containing up to 2^24 - 5 characters (16777211 characters); on > 64-bit platforms, the limit is 2^57 - 9. 312,313c332,335 < current implementation supports arrays containing to 2^22 - 1 elements (4194303 < elements). --- > current implementation supports arrays containing up to 2^22 - 1 elements > (4194303 elements) unless the elements are floating-point numbers (2097151 > elements in this case); on 64-bit platforms, the limit is 2^54 - 1 for all > arrays. 320,322c342,344 < constructor and a value. The former case is written cconstr; the latter case is < written ncconstr(v), where v is said to be the argument of the non-constant < constructor ncconstr. --- > constructor and a value. The former case is written constr; the latter case is > written constr(v), where v is said to be the argument of the non-constant > constructor constr. 325c347 < ----------------------------- --- > ---------------------------- 327,328c349,350 < ----------------------------- < |false |the boolean false | --- > ---------------------------- > | false |the boolean false| 330c352 < |() |the ``unit'' value| --- > |() |the "unit" value | 332c354 < ----------------------------- --- > ---------------------------- 334,335c356,357 < The current implementation limits the number of distinct constructors in a < given variant type to at most 249. --- > The current implementation limits each variant type to have at most 246 > non-constant constructors. 370,371c392 < - value constructors (constant -- class cconstr-name -- or non-constant -- < class ncconstr-name), --- > - value constructors and exception constructors (class constr-name), 381c402 < These nine name spaces are distinguished both by the context and by the --- > These eleven name spaces are distinguished both by the context and by the 387a409 > 393,400c415,423 < operator-name ::= prefix-symbol | infix-symbol | * | = | or | & | := < cconstr-name ::= capitalized-ident < | false < | true < | [ ] < | ( ) < ncconstr-name ::= capitalized-ident < | :: --- > > operator-name ::= prefix-symbol | infix-op > > infix-op ::= infix-symbol > | * | = | or | & | := > | mod | land | lor | lxor | lsl | lsr | asr > > constr-name ::= capitalized-ident > 401a425 > 402a427 > 403a429 > 404a431 > 405a433 > 406a435 > 407a437 > 408a439 > 411,413c442,443 < used as value names, provided they are written between parentheses. Keywords < such as '::' and 'false' are also constructor names. The capitalization rules < are summarized in the table below. --- > used as value names, provided they are written between parentheses. The > capitalization rules are summarized in the table below. 415c445 < ---------------------------------------- --- > ----------------------------------------- 417,418c447,448 < ---------------------------------------- < |Values |lowercase | --- > ----------------------------------------- > | Values |lowercase | 421,422c451,453 < |Variant tag |uppercase | < |Type constructors|lowercase | --- > |Variant tags |uppercase | > |Exceptions |uppercase | > |Type constructors |lowercase | 424a456 > |Instance variables|lowercase | 428c460 < ---------------------------------------- --- > ----------------------------------------- 433a466 > 438,442c471,475 < | module-path . lowercase-ident < cconstr ::= cconstr-name < | module-path . capitalized-ident < ncconstr ::= ncconstr-name < | module-path . capitalized-ident --- > | module-path . value-name > > constr ::= constr-name > | module-path . constr-name > 444c477,478 < | extended-module-path . lowercase-ident --- > | extended-module-path . typeconstr-name > 446c480,481 < | module-path . lowercase-ident --- > | module-path . field-name > 448c483,484 < | module-path . capitalized-ident --- > | module-path . module-name > 450c486 < | extended-module-path . capitalized-ident --- > | extended-module-path . module-name 451a488 > 453c490,491 < | extended-module-path . ident --- > | extended-module-path . modtype-name > 455c493 < | module-path . lowercase-ident --- > | module-path . class-name 470a509 > 479,483c518,520 < | [[?]ident:] typexpr -> typexpr < [+] < --- < | typexpr { * typexpr }[ ] < --- --- > | [[?]label-name:] typexpr -> typexpr > + > | typexpr { * typexpr } 488c525 < | [ variant-type ] --- > | variant-type 493a531 > 495,498c533,535 < [+] < --- < | { ' ident }[ ] . typexpr < --- --- > + > | { ' ident } . typexpr > 505c542 < -------------------------------------------- --- > --------------------------------------------- 507,508c544,545 < -------------------------------------------- < |Type constructor application|-- | --- > --------------------------------------------- > | Type constructor application|-- | 512c549 < -------------------------------------------- --- > --------------------------------------------- 516a554 > 525,526c563,572 < variable is the whole enclosing definition; they can only be generalized when < leaving this scope. Anonymous variables have no such restriction. --- > variable is the whole enclosing definition; and they can only be generalized > when leaving this scope. Anonymous variables have no such restriction. In the > following cases, the scope of named type variables is restricted to the type > expression where they appear: 1) for universal (explicitly polymorphic) type > variables; 2) for type variables that only appear in public method > specifications (as those variables will be made universal, as described in > section 6.9.1); 3) for variables used as aliases, when the type they are > aliased to would be invalid in the scope of the enclosing definition (i.e. when > it contains free universal type variables, or locally defined types.) > 532a579 > 538,540c585,587 < label typexpr_1 -> typexpr_2 denotes the same function type, but the argument < is labeled label. < ?label typexpr_1 -> typexpr_2 denotes the type of functions mapping an --- > label-name : typexpr_1 -> typexpr_2 denotes the same function type, but the > argument is labeled label. > optlabel typexpr_1 -> typexpr_2 denotes the type of functions mapping an 543a591 > 549a598 > 557,559c606,609 < The type expression (typexpr_1,...,typexpr_n) typeconstr, where typeconstr is < a type constructor with n parameters, denotes the application of the n-ary type < constructor typeconstr to the types typexpr_1 through typexpr_n. --- > The type expression (typexpr_1,..., typexpr_n) typeconstr, where typeconstr > is a type constructor with n parameters, denotes the application of the n-ary > type constructor typeconstr to the types typexpr_1 through typexpr_n. > 566,570c616,621 < also binds the type variable ident to type typexpr both in typexpr and in the < remaining part of the type. If the type variable ident actually occurs in < typexpr, a recursive type is created. Recursive types for which there exists a < recursive path that does not contain an object or variant type constructor are < rejected, except when the -rectypes mode is selected. --- > also binds the type variable ident to type typexpr both in typexpr and in other > types. In general the scope of an alias is the same as for a named type > variable, and covers the whole enclosing definition. If the type variable ident > actually occurs in typexpr, a recursive type is created. Recursive types for > which there exists a recursive path that does not contain an object or variant > type constructor are rejected, except when the -rectypes mode is selected. 574a626 > 578c630 < variant-type ::= [ | ] tag-spec { | tag-spec } --- > variant-type ::= [ [ | ] tag-spec { | tag-spec } ] 580c632 < | > [ tag-spec ] { | tag-spec } --- > | [> [ tag-spec ] { | tag-spec } ] 583c635,637 < [+] --- > + > | [< [ | ] tag-spec-full { | tag-spec-full } [ > { > `tag-name } ] ] 585,587d638 < --- < | < [ | ] tag-spec-full { | tag-spec-full } [ > { `tag-name < }[ ] ] 589d639 < --- 593a644,645 > > 598a651,652 > > 623a678 > 627c682,683 < An object type < method-type { ; method-type } > is a record of method types. --- > An object type < method-type { ; method-type } > is a record of method > types. 632,633c688,689 < The type < method-type { ; method-type } ; .. > is the type of an object with < methods and their associated types are described by method-type_1, ..., --- > The type < method-type { ; method-type } ; .. > is the type of an object > with methods and their associated types are described by method-type_1, ..., 637a694 > 652a710 > 669c727,731 < | cconstr --- > | constr > | false > | true > | [] > | () 674c736,737 < constructors from both normal and polymorphic variants. --- > constructors from both normal and polymorphic variants, as well as the special > constants false, true, [], and (), which behave like constant constructors. 688c751 < | ncconstr pattern --- > | constr pattern 701c764 < --------------------------------------- --- > ---------------------------------------- 703,704c766,767 < --------------------------------------- < |Constructor application|-- | --- > ---------------------------------------- > | Constructor application|-- | 709c772 < --------------------------------------- --- > ---------------------------------------- 713,715c776,779 < operation is called pattern matching; its outcome is either ``this value does < not match this pattern'', or ``this value matches this pattern, resulting in < the following bindings of names to values''. --- > operation is called pattern matching; its outcome is either "this value does > not match this pattern", or "this value matches this pattern, resulting in the > following bindings of names to values". > 726a791 > 732a798 > 740a807 > 746c813 < ). This constraint forces the type of pattern_1 to be compatible with type. --- > ). This constraint forces the type of pattern_1 to be compatible with typexpr. 748,749d814 < ``Or'' patterns < --------------- 751c816,819 < The pattern pattern_1 | pattern_2 represents the logical ``or'' of the two --- > "Or" patterns > ------------- > > The pattern pattern_1 | pattern_2 represents the logical "or" of the two 755,758c823,827 < the same types. The bindings performed by matching against an ``or'' pattern < are either those performed by the matching against pattern_1, if it succeeds, < or those performed by the matching against pattern_2, if it succeeds. If both < matchings succeed, it is undefined which set of bindings is selected. --- > the same types. Matching is performed from left to right. More precisely, in > case some value v matches pattern_1 | pattern_2, the bindings performed are > those of pattern_1 when v matches pattern_1. Otherwise, value v matches > pattern_2 whose bindings are performed. > 763,764c832,833 < The pattern ncconstr pattern_1 matches all variants whose constructor is < equal to ncconstr, and whose argument matches pattern_1. --- > The pattern constr pattern_1 matches all variants whose constructor is equal > to constr, and whose argument matches pattern_1. 766,767c835 < pattern_1, and whose tails match pattern_2. This pattern behaves like ( :: ) ( < pattern_1 , pattern_2 ). --- > pattern_1, and whose tails match pattern_2. 771a840 > 777a847 > 781,784c851,855 < If the type [('a,'b,...)] typeconstr = [`tag_1 t_1 | ... | `tag_n t_n] is < defined, then the pattern #typeconstr is a shorthand for the or-pattern < (`tag_1(_ : t_1) | ... | `tag_n(_ : t_n)). It matches all values of type < #typeconstr. --- > If the type [('a,'b,...)] typeconstr = [`tag_1 typexpr_1 | ... | `tag_n > typexpr_n] is defined, then the pattern #typeconstr is a shorthand for the > or-pattern (`tag_1(_ : typexpr_1) | ... | `tag_n(_ : typexpr_n)). It matches > all values of type #typeconstr. > 793a865 > 802a875 > 806,807c879,881 < The pattern [| pattern_1 ; ... ; pattern_n |] matches arrays of length n such < that the i-th array element matches the pattern pattern_i, for i = 1,... , n. --- > The pattern [| pattern_1 ; ... ; pattern_n |] matches arrays of length n > such that the i-th array element matches the pattern pattern_i, for i = 1,... , > n. 815a890 > 816a892 > 817a894 > 818a896 > 819a898 > 821c900,902 < | ncconstr expr --- > > | constr expr > 822a904 > 823a906 > 824a908 > 825a910 > 826a912 > 828,831c914,918 < [+] < --- < | expr { argument }[ ] < --- --- > > + > > | expr { argument } > 832a920 > 833a922 > 834a924 > 835a926 > 836a928 > 837a930 > 838a932 > 839a934 > 840a936 > 841a938 > 842a940 > 843a942 > 844a944 > 845a946 > 846a948 > 847a950 > 848a952 > 849a954,956 > > | object class-body end > 850a958,962 > > | inst-var-name > > | inst-var-name <- expr > 851a964 > 853c966,974 < | {< inst-var-name = expr { ; inst-var-name = expr } >} --- > > | {< inst-var-name = expr { ; inst-var-name = expr } > >} > | assert expr > > | lazy expr > > > 854a976 > 855a978 > 856a980 > 857a982 > 860,862d984 < pattern-matching ::= [ | ] pattern [when expr] -> expr { | pattern [when < expr] -> expr } < [+] 864d985 < --- 866c987,989 < multiple-matching ::= { parameter }[ ] [when expr] -> expr --- > pattern-matching ::= [ | ] pattern [when expr] -> expr { | pattern > [when expr] -> expr } > 868c991 < --- --- > + 870c993 < let-binding ::= pattern [: typexpr] = expr --- > multiple-matching ::= { parameter } [when expr] -> expr 872d994 < [+] 874d995 < --- 876c997,1000 < | value-name { parameter }[ ] [: typexpr] = expr --- > let-binding ::= pattern = expr > > | value-name { parameter } [: typexpr] = expr > 878d1001 < --- 896,899d1018 < infix-op ::= infix-symbol < < | * | = | or | & < 903,904c1022,1023 < first. For infix and prefix symbols, we write ``*...'' to mean ``any symbol < starting with *''. --- > first. For infix and prefix symbols, we write "*..." to mean "any symbol > starting with *". 906c1025 < --------------------------------------------------------------------- --- > --------------------------------------------------------------------------- 908,909c1027,1028 < --------------------------------------------------------------------- < |prefix-symbol |-- | --- > --------------------------------------------------------------------------- > | prefix-symbol |-- | 911,912c1030 < |function application |left | < |constructor application |-- | --- > |function application, constructor application, assert, lazy|left | 914,916c1032,1034 < |**... |right | < |*... /... %... mod |left | < |+... -... |left | --- > |**... lsl lsr asr |right | > |*... /... %... mod land lor lxor |left | > | +... -... |left | 918,920c1036,1037 < |@...^... |right | < |comparisons (= == < etc.), all other infix symbols|left | < |not |-- | --- > |@... ^... |right | > |comparisons (= == < etc.), all other infix symbols |left | 928c1045 < --------------------------------------------------------------------- --- > --------------------------------------------------------------------------- 935a1053 > 940a1059 > 947a1067 > 958,961c1078,1083 < Parenthesized expressions can contain a type constraint, as in ( expr : type < ). This constraint forces the type of expr to be compatible with type. < Parenthesized expressions can also contain coercions ( expr [: type] :> type) < (see subsection 6.7.5 below). --- > Parenthesized expressions can contain a type constraint, as in ( expr : > typexpr ). This constraint forces the type of expr to be compatible with > typexpr. > Parenthesized expressions can also contain coercions ( expr [: typexpr] :> > typexpr) (see subsection 6.7.5 below). > 993a1116 > 999,1004c1122,1124 < [ ] [ ] < --- --- < [ ] [ ] < function pattern--- -> expr--- < [1] [1] < --- --- --- > > function pattern -> expr > 1 1 1006,1011c1126,1128 < [ ] [ ] < --- --- < [ ] [ ] < | pattern--- -> expr--- < [n] [n] < --- --- --- > > | pattern -> expr > n n 1030,1042c1147,1149 < [ ] < < --- < < [ ] < < fun optlabel x -> let pattern = match x with Some x -> x | None -> expr--- < in expr < [0] < < --- < < where x is a fresh variable. When expr_0 will be evaluated is left --- > fun optlabel ident -> let pattern = match ident with Some ident -> > ident | None -> expr_0 in expr > where ident is a fresh variable. When expr_0 will be evaluated is left 1055a1163 > 1063,1068c1171,1173 < [ ] [ ] [ ] < --- --- --- < [ ] [ ] [ ] < function pattern--- [when cond---] -> expr--- < [1] [1] [1] < --- --- --- --- > > function pattern [when cond ] -> expr > 1 1 1 1070,1075c1175,1177 < [ ] [ ] [ ] < --- --- --- < [ ] [ ] [ ] < | pattern--- [when cond---] -> expr--- < [n] [n] [n] < --- --- --- --- > > | pattern [when cond ] -> expr > n n n 1083a1186 > 1109,1110c1212,1213 < one of the patterns pattern_1, ..., pattern_n, and expect them to have the same < value as in expr, the body of the let rec construct. --- > one of the patterns pattern_1, ..., pattern_n, and expect them to have the > same value as in expr, the body of the let rec construct. 1119,1124c1222,1223 < class of recursive definitions of non-functional values, such as < let rec name_1 = 1 :: name_2 and name_2 = 2 :: name_1 in expr < which binds name_1 to the cyclic list 1::2::1::2::..., and name_2 to the < cyclic list 2::1::2::1::...Informally, the class of accepted definitions < consists of those definitions where the defined names occur only inside < function bodies or as argument to a data constructor. --- > class of recursive definitions of non-functional values, as explained in > section 7.3. 1130a1230 > 1136a1237 > 1144a1246 > 1150,1155c1252,1254 < [ ] [ ] < --- --- < [ ] [ ] < with pattern--- -> expr--- < [1] [1] < --- --- --- > > with pattern -> expr > 1 1 1157,1162c1256,1258 < [ ] [ ] < --- --- < [ ] [ ] < | pattern--- -> expr--- < [n] [n] < --- --- --- > > | pattern -> expr > n n 1170a1267 > 1181,1185c1278,1282 < The expression expr_1 || expr_2 evaluates to true if one of expr_1 and expr_2 < evaluates to true; otherwise, it evaluates to false. The first component, < expr_1, is evaluated first. The second component, expr_2, is not evaluated if < the first component evaluates to true. Hence, the expression expr_1 || expr_2 < behaves exactly as --- > The expression expr_1 || expr_2 evaluates to true if one of expr_1 and > expr_2 evaluates to true; otherwise, it evaluates to false. The first > component, expr_1, is evaluated first. The second component, expr_2, is not > evaluated if the first component evaluates to true. Hence, the expression > expr_1 || expr_2 behaves exactly as 1190a1288 > 1194,1197c1292,1295 < The expression while expr_1 do expr_2 done repeatedly evaluates expr_2 while < expr_1 evaluates to true. The loop condition expr_1 is evaluated and tested at < the beginning of each iteration. The whole while ... done expression evaluates < to the unit value (). --- > The expression while expr_1 do expr_2 done repeatedly evaluates expr_2 > while expr_1 evaluates to true. The loop condition expr_1 is evaluated and > tested at the beginning of each iteration. The whole while ... done expression > evaluates to the unit value (). 1201,1202c1299,1300 < is successively bound to the values n, n+1, ..., p-1, p. The loop body is < never evaluated if n > p. --- > is successively bound to the values n, n+1, ..., p-1, p. The loop body is never > evaluated if n > p. 1207a1306 > 1213,1218c1312,1314 < [ ] [ ] < --- --- < [ ] [ ] < with pattern--- -> expr--- < [1] [1] < --- --- --- > > with pattern -> expr > 1 1 1220,1225c1316,1318 < [ ] [ ] < --- --- < [ ] [ ] < | pattern--- -> expr--- < [n] [n] < --- --- --- > > | pattern -> expr > n n 1235c1328 < thereby transparently ``passing through'' the try construct. --- > thereby transparently "passing through" the try construct. 1241a1335 > 1248a1343 > 1252,1253c1347,1348 < The expression ncconstr expr evaluates to the variant value whose constructor < is ncconstr, and whose argument is the value of expr. --- > The expression constr expr evaluates to the variant value whose constructor > is constr, and whose argument is the value of expr. 1255,1257c1350,1352 < stands for the constructor ( :: ) applied to the argument ( expr_1 , expr_2 ), < and therefore evaluates to the list whose head is the value of expr_1 and whose < tail is the value of expr_2. The expression [ expr_1 ; ... ; expr_n ] is --- > stands for the constructor ( :: ) applied to the argument ( expr_1 , expr_2 > ), and therefore evaluates to the list whose head is the value of expr_1 and > whose tail is the value of expr_2. The expression [ expr_1 ; ... ; expr_n ] is 1260a1356 > 1266a1363 > 1270,1282c1367,1379 < The expression { field_1 = expr_1 ; ... ; field_n = expr_n } evaluates to the < record value { field_1 = v_1 ; ... ; field_n = v_n }, where v_i is the value of < expr_i for i = 1,... , n. The fields field_1 to field_n must all belong to the < same record types; all fields belonging to this record type must appear exactly < once in the record expression, though they can appear in any order. The order < in which expr_1 to expr_n are evaluated is not specified. < The expression { expr with field_1 = expr_1 ; ... ; field_n = expr_n } builds < a fresh record with fields field_1 ... field_n equal to expr_1 ... expr_n, and < all other fields having the same value as in the record expr. In other terms, < it returns a shallow copy of the record expr, except for the fields field_1 ... < field_n, which are initialized to expr_1 ... expr_n. < The expression expr_1 . field evaluates expr_1 to a record value, and returns < the value associated to field in this record value. --- > The expression { field_1 = expr_1 ; ... ; field_n = expr_n } evaluates to > the record value { field_1 = v_1; ...; field_n = v_n } where v_i is the value > of expr_i for i = 1,... , n. The fields field_1 to field_n must all belong to > the same record types; all fields belonging to this record type must appear > exactly once in the record expression, though they can appear in any order. The > order in which expr_1 to expr_n are evaluated is not specified. > The expression { expr with field_1 = expr_1 ; ... ; field_n = expr_n } > builds a fresh record with fields field_1 ... field_n equal to expr_1 ... > expr_n, and all other fields having the same value as in the record expr. In > other terms, it returns a shallow copy of the record expr, except for the > fields field_1 ... field_n, which are initialized to expr_1 ... expr_n. > The expression expr_1 . field evaluates expr_1 to a record value, and > returns the value associated to field in this record value. 1288a1386 > 1304a1403 > 1329c1428 < expr_2. --- > expr_2. 1338c1437 < |+ |Integer addition. | --- > | + |Integer addition. | 1344,1346c1443 < | |argument is zero. The result is | < | |unspecified if either argument is | < | |negative. | --- > | |argument is zero. | 1349,1352c1446,1450 < | |argument is zero. The result is | < | |unspecified if either argument is | < | |negative. | < |land |Bitwise logical ``and'' on | --- > | |argument is zero. | > |land |Bitwise logical "and" on integers.| > | | | > |lor |Bitwise logical "or" on integers. | > |lxor |Bitwise logical "exclusive or" on | 1354,1357d1451 < |lor |Bitwise logical ``or'' on | < | |integers. | < |lxor |Bitwise logical ``exclusive or'' | < | |on integers. | 1382,1385c1476,1479 < |< |Test ``less than''. | < |<= |Test ``less than or equal''. | < |> |Test ``greater than''. | < |>= |Test ``greater than or equal''. | --- > |< |Test "less than". | > |<= |Test "less than or equal". | > |> |Test "greater than". | > |>= |Test "greater than or equal". | 1393a1488 > 1403a1499,1514 > > Immediate object creation > ------------------------- > > > Creating directly an object through the object class-body end construct is > operationally equivalent to defining locally a class class-name = object > class-body end ---see sections 6.9.2 and following for the syntax of > class-body--- and immediately creating a single object from it by new > class-name. > The typing of immediate objects is slightly different from explicitely > defining a class in two respects. First, the inferred object type may contain > free type variables. Second, since the class body of an immediate object will > never be extended, its self type can be unified with a closed object type. > > 1413a1525,1536 > > Accessing and modifying instance variables > ------------------------------------------ > > The instance variables of a class are visible only in the body of the methods > defined in the same class or a class that inherits from the class defining the > instance variables. The expression inst-var-name evaluates to the value of the > given instance variable. The expression inst-var-name <- expr assigns the > value of expr to the instance variable inst-var-name, which must be mutable. > The whole expression inst-var-name <- expr evaluates to (). > > 1418,1419c1541,1542 < expression ( expr :> typexpr ) coerces the expression expr to type typexpr. The < expression ( expr : typexpr_1 :> typexpr_2 ) coerces the expression expr from --- > expression (expr :> typexpr) coerces the expression expr to type typexpr. The > expression (expr : typexpr_1 :> typexpr_2) coerces the expression expr from 1428a1552 > 1433c1557 < 20.21 ). Inside a method, the expression {< inst-var-name = expr { ; --- > 20.21). Inside a method, the expression {< inst-var-name = expr { ; 1454a1579,1580 > > 1456a1583,1584 > > 1458a1587,1588 > > 1460a1591,1592 > > 1464a1597,1598 > > 1468a1603,1604 > > 1475d1610 < constr-decl ::= cconstr-name 1477c1612,1617 < | ncconstr-name of typexpr --- > > constr-decl ::= constr-name > > | constr-name of typexpr { * typexpr } > > 1482a1623,1624 > > 1485a1628,1629 > > 1494,1502c1638,1652 < constructors with one parameter, or a list of type variables < ('ident_1,...,'ident_n), for type constructors with several parameters. Each < type parameter may be prefixed by a variance constraint + (resp. -) indicating < that the parameter is covariant (resp. contravariant). These type parameters < can appear in the type expressions of the right-hand side of the definition, < restricted eventually by a variance constraint ; i.e. a covariant parameter may < only appear on the right side of a functional arrow (more precisely, follow the < left branch of an even number of arrows), and a convariant parameter only the < left side (left branch of an odd number of arrows). --- > constructors with one parameter, or a list of type variables ('ident_1,...,' > ident_n), for type constructors with several parameters. Each type parameter > may be prefixed by a variance constraint + (resp. -) indicating that the > parameter is covariant (resp. contravariant). These type parameters can appear > in the type expressions of the right-hand side of the definition, restricted > eventually by a variance constraint ; i.e. a covariant parameter may only > appear on the right side of a functional arrow (more precisely, follow the left > branch of an even number of arrows), and a contravariant parameter only the > left side (left branch of an odd number of arrows). If the type has either a > representation or an equation, and the parameter is free (i.e. not bound via a > type constraint to a constructed type), its variance constraint is checked but > subtyping etc. will use the inferred variance of the parameter, which may be > better; otherwise (i.e. for abstract types or non-free parameters), the > variance must be given explicitly, and the parameter is invariant if no > variance was given. 1515,1518c1665,1668 < ncconstr-name of typexpr declares the name ncconstr-name as a non-constant < constructor, whose argument has type typexpr. The constructor declaration < cconstr-name declares the name cconstr-name as a constant constructor. < Constructor names must be capitalized. --- > constr-name of typexpr_1, ..., typexpr_n declares the name constr-name as a > non-constant constructor, whose arguments have types typexpr_1 ...typexpr_n. > The constructor declaration constr-name declares the name constr-name as a > constant constructor. Constructor names must be capitalized. 1560c1710 < subtyping relations when checking the validity of >: coercions (see section --- > subtyping relations when checking the validity of :> coercions (see section 1586,1588c1736,1737 < exception-definition ::= exception constr-decl < | exception cconstr-name = cconstr < | exception ncconstr-name = ncconstr --- > exception-definition ::= exception constr-name [of typexpr { * typexpr }] > | exception constr-name = constr 1593,1595c1742,1744 < The form exception constr-decl generates a new exception, distinct from all < other exceptions in the system. The form exception name = constr gives an < alternate name to an existing exception. --- > The form exception constr-name [of typexpr { * typexpr }] generates a new > exception, distinct from all other exceptions in the system. The form exception > constr-name = constr gives an alternate name to an existing exception. 1611,1613c1760,1762 < class-type ::= < | class-body-type < | [[?]label]typexpr -> class-type --- > class-type ::= class-body-type > | [[?]label-name:] typexpr -> class-type > 1616a1766 > 1618c1768 < | val [mutable] inst-var-name : typexpr --- > | val [mutable] [virtual] inst-var-name : typexpr 1623a1774,1775 > > 1628,1631c1780,1784 < class-path. Similarly, the expression [ typexpr_1 , ... typexpr_n ] class-path < is equivalent to the parametric class type bound to the name class-path, in < which type parameters have been instanciated to respectively typexpr_1, < ...typexpr_n. --- > class-path. Similarly, the expression [ typexpr_1 , ... typexpr_n ] > class-path is equivalent to the parametric class type bound to the name > class-path, in which type parameters have been instanciated to respectively > typexpr_1, ...typexpr_n. > 1639a1793 > 1655a1810 > 1663a1819 > 1668c1824 < A specification of an instance variable is written val [mutable] --- > A specification of an instance variable is written val [mutable] [virtual] 1671c1827,1829 < instance variable can be physically modified. --- > instance variable can be physically modified. The flag virtual indicates that > this instance variable is not initialized. It can be initialized later through > inheritance. 1674a1833 > 1681,1687c1840,1846 < expected type, possibly polymorphic. The flag private indicates whether the < method can be accessed from outside the class. < The polymorphism may be left implicit in method specifications: any type < variable which is not bound to a class parameter and does not appear elsewhere < inside the class specification will be assumed to be polymorphic, and made < explicit in the resulting method type. Writing an explicit polymorphic type < will disable this behaviour. --- > expected type, possibly polymorphic. The flag private indicates that the method > cannot be accessed from outside the object. > The polymorphism may be left implicit in public method specifications: any > type variable which is not bound to a class parameter and does not appear > elsewhere inside the class specification will be assumed to be universal, and > made polymorphic in the resulting method type. Writing an explicit polymorphic > type will disable this behaviour. 1690a1850 > 1698a1859 > 1715a1877 > 1716a1879 > 1717a1881 > 1719,1726c1883,1891 < [+] < --- < | class-expr {argument}[ ] < --- < [+] < --- < | fun {parameter}[ ] -> class-expr < --- --- > > + > > | class-expr {argument} > > + > > | fun {parameter} -> class-expr > 1727a1893 > 1728a1895,1897 > > > 1729a1899 > 1731c1901,1905 < | method [private] method-name {pattern} [: typexpr] = expr --- > > | val [mutable] virtual inst-var-name : typexpr > > | method [private] method-name {parameter} [: typexpr] = > expr 1732a1907 > 1733a1909 > 1734a1911 > 1737a1915,1918 > > > > 1742,1744c1923,1926 < class-path. Similarly, the expression [ typexpr_1 , ... typexpr_n ] class-path < evaluates to the parametric class bound to the name class-path, in which type < parameters have been instanciated to respectively typexpr_1, ...typexpr_n. --- > class-path. Similarly, the expression [ typexpr_1 , ... typexpr_n ] > class-path evaluates to the parametric class bound to the name class-path, in > which type parameters have been instanciated to respectively typexpr_1, > ...typexpr_n. 1751a1934 > 1757a1941 > 1761,1764c1945,1948 < The expression fun [[?]label]pattern -> class-expr evaluates to a function < from values to classes. When this function is applied to a value v, this value < is matched against the pattern pattern and the result is the result of the < evaluation of class-expr in the extended environment. --- > The expression fun [[?]label-name:] pattern -> class-expr evaluates to a > function from values to classes. When this function is applied to a value v, > this value is matched against the pattern pattern and the result is the result > of the evaluation of class-expr in the extended environment. 1772a1957 > 1778a1964 > 1782,1784c1968,1971 < The expression object ( pattern [: typexpr] ) { class-field } end denotes a < class body. This is the prototype for an object : it lists the instance < variables and methods of an objet of this class. --- > class-body ::= [( pattern [: typexpr] )] { class-field } > The expression object class-body end denotes a class body. This is the > prototype for an object : it lists the instance variables and methods of an > objet of this class. 1787,1789c1974,1976 < In a class body, the pattern ( pattern [: typexpr] ) is matched against self, < therefore provinding a binding for self and self type. Self can only be used in < method and initializers. --- > In a class body, the pattern ( pattern [: typexpr] ) is matched against > self, therefore provinding a binding for self and self type. Self can only be > used in method and initializers. 1792a1980 > 1809a1998 > 1815,1817c2004,2005 < inst-var-name whose initial value is the value of expression expr. Several < variables of the same name can be defined in the same class. The flag mutable < allows physical modification of this variable by methods. --- > inst-var-name whose initial value is the value of expression expr. The flag > mutable allows physical modification of this variable by methods. 1819a2008,2022 > Since version 3.10, redefinitions of a visible instance variable with the > same name do not create a new variable, but are merged, using the last value > for initialization. They must have identical types and mutability. However, if > an instance variable is hidden by omitting it from an interface, it will be > kept distinct from other instance variables with the same name. > > > Virtual instance variable definition > ------------------------------------ > > > Variable specification is written val [mutable] virtual inst-var-name : > typexpr. It specifies whether the variable is modifiable, and gives its type. > Virtual instance variables were added in version 3.10. > 1829,1832c2032,2035 < only be invoked on self (from other methods of the current class as well as of < subclasses of the current class). This invocation is performed using the < expression value-name # method-name, where value-name is directly bound to self < at the beginning of the class definition. Private methods do not appear in --- > only be invoked on self (from other methods of the same object, defined in this > class or one of its subclasses). This invocation is performed using the > expression value-name # method-name, where value-name is directly bound to > self at the beginning of the class definition. Private methods do not appear in 1848a2052 > 1856a2061 > 1865a2071 > 1873a2080 > 1889,1890c2096,2101 < class-binding ::= [virtual] [[ type-parameters ]] class-name { pattern < } [: class-type] = class-expr --- > > > class-binding ::= [virtual] [[ type-parameters ]] class-name > {parameter} [: class-type] = class-expr > > 1893a2105,2106 > > 1903a2117 > 1910a2125 > 1926a2142,2143 > > 1929a2147,2148 > > 1940a2160,2161 > > 1943a2165,2166 > > 1970a2194,2201 > > > mod-constraint ::= type [type-parameters] typeconstr = typexpr > > | module module-path = extended-module-path > > > 1995d2225 < mod-constraint ::= type [type-parameters] typeconstr = typexpr 1997d2226 < | module module-path = extended-module-path 2022a2252 > 2034a2265 > 2043,2048c2274,2280 < typexp and an optional type representation = constr-decl ... or = { label-decl < ... }. The implementation of the type name in a matching structure must be < compatible with the type expression specified in the equation (if given), and < have the specified representation (if given). Conversely, users of that < signature will be able to rely on the type equation or type representation, if < given. More precisely, we have the following four situations: --- > typexpr and an optional type representation = constr-decl ... or = { > field-decl ... }. The implementation of the type name in a matching structure > must be compatible with the type expression specified in the equation (if > given), and have the specified representation (if given). Conversely, users of > that signature will be able to rely on the type equation or type > representation, if given. More precisely, we have the following four > situations: 2063,2065c2295,2297 < Type abbreviation: an equation = typexp, no representation. < The type name must be implemented by a type compatible with typexp. All users < of the structure know that the type name is compatible with typexp. --- > Type abbreviation: an equation = typexpr, no representation. > The type name must be implemented by a type compatible with typexpr. All users > of the structure know that the type name is compatible with typexpr. 2078a2311 > 2086a2320 > 2095a2330 > 2104a2340 > 2115,2116c2351,2352 < module module-name ( name_1 : module-type_1 ) ... ( name_n : module-type_n < ) : module-type --- > module module-name ( name_1 : module-type_1 ) ... ( name_n : > module-type_n ) : module-type 2121a2358 > 2169c2406 < a functor may take another functor as argument (``higher-order'' functor). --- > a functor may take another functor as argument ("higher-order" functor). 2180,2181c2417,2418 < [type-parameters] typeconstr = typexp adds the type equation = typexp to the < specification of the type component named typeconstr of the constrained --- > [type-parameters] typeconstr = typexpr adds the type equation = typexpr to > the specification of the type component named typeconstr of the constrained 2187,2188c2424 < << < sig type t module M: (sig type u end) end --- > << sig type t module M: (sig type u end) end 2191,2192c2427 < << < sig type t=int module M: (sig type u end) end --- > << sig type t=int module M: (sig type u end) end 2195,2196c2430 < << < sig type t module M: (sig type u=N.u end) end --- > << sig type t module M: (sig type u=N.u end) end 2200,2201c2434 < << < functor (A: S) (B: S with type t = A.t) ... --- > << functor (A: S) (B: S with type t = A.t) ... 2203a2437,2440 > Constraints are added left to right. After each constraint has been applied, > the resulting signature must be a subtype of the signature before the > constraint was applied. Thus, the with operator can only add information on the > type components of a signature, but never remove information. 2225a2463,2464 > > 2239,2241c2478 < module-type ] < = module-expr < --- > module-type ] = module-expr 2281a2519 > 2286,2288c2524,2526 < A value definition let [rec] let-binding { and let-binding } bind value names < in the same way as a let ... in ... expression (see section 6.7.1). The value < names appearing in the left-hand sides of the bindings are bound to the --- > A value definition let [rec] let-binding { and let-binding } bind value > names in the same way as a let ... in ... expression (see section 6.7.1). The > value names appearing in the left-hand sides of the bindings are bound to the 2294a2533 > 2302a2542 > 2309a2550 > 2317a2559 > 2326a2569 > 2339,2340c2582,2583 < module module-name ( name_1 : module-type_1 ) ... ( name_n : module-type_n < ) = module-expr --- > module module-name ( name_1 : module-type_1 ) ... ( name_n : > module-type_n ) = module-expr 2345a2589 > 2353a2598 > 2363a2609 > 2371,2372c2617 < << < struct type t = int let x = 2 end --- > << struct type t = int let x = 2 end 2375,2376c2620 < << < struct include S let y = (x + 1 : t) end --- > << struct include S let y = (x + 1 : t) end 2379,2380c2623 < << < struct type t = int let x = 2 let y = (x + 1 : t) end --- > << struct type t = int let x = 2 let y = (x + 1 : t) end 2391a2635 > 2396,2401c2640,2646 < The expression functor ( module-name : module-type ) -> module-expr evaluates < to a functor that takes as argument modules of the type module-type_1, binds < module-name to these modules, evaluates module-expr in the extended < environment, and returns the resulting modules as results. No restrictions are < placed on the type of the functor argument; in particular, a functor may take < another functor as argument (``higher-order'' functor). --- > The expression functor ( module-name : module-type ) -> module-expr > evaluates to a functor that takes as argument modules of the type > module-type_1, binds module-name to these modules, evaluates module-expr in the > extended environment, and returns the resulting modules as results. No > restrictions are placed on the type of the functor argument; in particular, a > functor may take another functor as argument ("higher-order" functor). > 2417a2663 > 2438c2684 < name_1 : sig interface_1 end ... name_n : sig interface_n end --- > name_1 : sig specification_1 end ... name_n : sig specification_n end 2440,2441c2686,2687 < available in the search path (see chapter 8 for more details) and interface_1 < ... interface_n are their respective interfaces. --- > available in the search path (see chapter 8 for more details) and > specification_1 ... specification_n are their respective interfaces. |