1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
|
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="Start" href="index.html">
<link rel="previous" href="Parsing.html">
<link rel="next" href="Printexc.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Arg" rel="Chapter" href="Arg.html">
<link title="Arith_status" rel="Chapter" href="Arith_status.html">
<link title="Array" rel="Chapter" href="Array.html">
<link title="ArrayLabels" rel="Chapter" href="ArrayLabels.html">
<link title="Big_int" rel="Chapter" href="Big_int.html">
<link title="Bigarray" rel="Chapter" href="Bigarray.html">
<link title="Buffer" rel="Chapter" href="Buffer.html">
<link title="Callback" rel="Chapter" href="Callback.html">
<link title="CamlinternalMod" rel="Chapter" href="CamlinternalMod.html">
<link title="CamlinternalOO" rel="Chapter" href="CamlinternalOO.html">
<link title="Char" rel="Chapter" href="Char.html">
<link title="Complex" rel="Chapter" href="Complex.html">
<link title="Condition" rel="Chapter" href="Condition.html">
<link title="Dbm" rel="Chapter" href="Dbm.html">
<link title="Digest" rel="Chapter" href="Digest.html">
<link title="Dynlink" rel="Chapter" href="Dynlink.html">
<link title="Event" rel="Chapter" href="Event.html">
<link title="Filename" rel="Chapter" href="Filename.html">
<link title="Format" rel="Chapter" href="Format.html">
<link title="Gc" rel="Chapter" href="Gc.html">
<link title="Genlex" rel="Chapter" href="Genlex.html">
<link title="Graphics" rel="Chapter" href="Graphics.html">
<link title="GraphicsX11" rel="Chapter" href="GraphicsX11.html">
<link title="Hashtbl" rel="Chapter" href="Hashtbl.html">
<link title="Int32" rel="Chapter" href="Int32.html">
<link title="Int64" rel="Chapter" href="Int64.html">
<link title="Lazy" rel="Chapter" href="Lazy.html">
<link title="Lexing" rel="Chapter" href="Lexing.html">
<link title="List" rel="Chapter" href="List.html">
<link title="ListLabels" rel="Chapter" href="ListLabels.html">
<link title="Map" rel="Chapter" href="Map.html">
<link title="Marshal" rel="Chapter" href="Marshal.html">
<link title="MoreLabels" rel="Chapter" href="MoreLabels.html">
<link title="Mutex" rel="Chapter" href="Mutex.html">
<link title="Nativeint" rel="Chapter" href="Nativeint.html">
<link title="Num" rel="Chapter" href="Num.html">
<link title="Obj" rel="Chapter" href="Obj.html">
<link title="Oo" rel="Chapter" href="Oo.html">
<link title="Parsing" rel="Chapter" href="Parsing.html">
<link title="Pervasives" rel="Chapter" href="Pervasives.html">
<link title="Printexc" rel="Chapter" href="Printexc.html">
<link title="Printf" rel="Chapter" href="Printf.html">
<link title="Queue" rel="Chapter" href="Queue.html">
<link title="Random" rel="Chapter" href="Random.html">
<link title="Scanf" rel="Chapter" href="Scanf.html">
<link title="Set" rel="Chapter" href="Set.html">
<link title="Sort" rel="Chapter" href="Sort.html">
<link title="Stack" rel="Chapter" href="Stack.html">
<link title="StdLabels" rel="Chapter" href="StdLabels.html">
<link title="Str" rel="Chapter" href="Str.html">
<link title="Stream" rel="Chapter" href="Stream.html">
<link title="String" rel="Chapter" href="String.html">
<link title="StringLabels" rel="Chapter" href="StringLabels.html">
<link title="Sys" rel="Chapter" href="Sys.html">
<link title="Thread" rel="Chapter" href="Thread.html">
<link title="ThreadUnix" rel="Chapter" href="ThreadUnix.html">
<link title="Unix" rel="Chapter" href="Unix.html">
<link title="UnixLabels" rel="Chapter" href="UnixLabels.html">
<link title="Weak" rel="Chapter" href="Weak.html"><link title="Exceptions" rel="Section" href="#6_Exceptions">
<link title="Comparisons" rel="Section" href="#6_Comparisons">
<link title="Boolean operations" rel="Section" href="#6_Booleanoperations">
<link title="Integer arithmetic" rel="Section" href="#6_Integerarithmetic">
<link title="Floating-point arithmetic" rel="Section" href="#6_Floatingpointarithmetic">
<link title="String operations" rel="Section" href="#6_Stringoperations">
<link title="Character operations" rel="Section" href="#6_Characteroperations">
<link title="Unit operations" rel="Section" href="#6_Unitoperations">
<link title="String conversion functions" rel="Section" href="#6_Stringconversionfunctions">
<link title="Pair operations" rel="Section" href="#6_Pairoperations">
<link title="List operations" rel="Section" href="#6_Listoperations">
<link title="Input/output" rel="Section" href="#6_Inputoutput">
<link title="References" rel="Section" href="#6_References">
<link title="Operations on format strings" rel="Section" href="#6_Operationsonformatstrings">
<link title="Program termination" rel="Section" href="#6_Programtermination">
<link title="Bitwise operations" rel="Subsection" href="#7_Bitwiseoperations">
<link title="Output functions on standard output" rel="Subsection" href="#7_Outputfunctionsonstandardoutput">
<link title="Output functions on standard error" rel="Subsection" href="#7_Outputfunctionsonstandarderror">
<link title="Input functions on standard input" rel="Subsection" href="#7_Inputfunctionsonstandardinput">
<link title="General output functions" rel="Subsection" href="#7_Generaloutputfunctions">
<link title="General input functions" rel="Subsection" href="#7_Generalinputfunctions">
<link title="Operations on large files" rel="Subsection" href="#7_Operationsonlargefiles">
<title>Pervasives</title>
</head>
<body>
<div class="navbar"><a href="Parsing.html">Previous</a>
<a href="index.html">Up</a>
<a href="Printexc.html">Next</a>
</div>
<center><h1>Module <a href="type_Pervasives.html">Pervasives</a></h1></center>
<br>
<pre><span class="keyword">module</span> Pervasives: <code class="code"><span class="keyword">sig</span></code> <a href="Pervasives.html">..</a> <code class="code"><span class="keyword">end</span></code></pre>The initially opened module.
<p>
This module provides the basic operations over the built-in types
(numbers, booleans, strings, exceptions, references, lists, arrays,
input-output channels, ...)
<p>
This module is automatically opened at the beginning of each compilation.
All components of this module can therefore be referred by their short
name, without prefixing them by <code class="code"><span class="constructor">Pervasives</span></code>.<br>
<hr width="100%">
<br>
<a name="6_Exceptions"></a>
<h6>Exceptions</h6><br>
<pre><span class="keyword">val</span> <a name="VALraise"></a>raise : <code class="type">exn -> 'a</code></pre><div class="info">
Raise the given exception value<br>
</div>
<pre><span class="keyword">val</span> <a name="VALinvalid_arg"></a>invalid_arg : <code class="type">string -> 'a</code></pre><div class="info">
Raise exception <code class="code"><span class="constructor">Invalid_argument</span></code> with the given string.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfailwith"></a>failwith : <code class="type">string -> 'a</code></pre><div class="info">
Raise exception <code class="code"><span class="constructor">Failure</span></code> with the given string.<br>
</div>
<pre><span class="keyword">exception</span> <a name="EXCEPTIONExit"></a>Exit</pre>
<div class="info">
The <code class="code"><span class="constructor">Exit</span></code> exception is not raised by any library function. It is
provided for use in your programs.<br>
</div>
<br>
<a name="6_Comparisons"></a>
<h6>Comparisons</h6><br>
<pre><span class="keyword">val</span> <a name="VAL(=)"></a>(=) : <code class="type">'a -> 'a -> bool</code></pre><div class="info">
<code class="code">e1 = e2</code> tests for structural equality of <code class="code">e1</code> and <code class="code">e2</code>.
Mutable structures (e.g. references and arrays) are equal
if and only if their current contents are structurally equal,
even if the two mutable objects are not the same physical object.
Equality between functional values raises <code class="code"><span class="constructor">Invalid_argument</span></code>.
Equality between cyclic data structures does not terminate.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(<>)"></a>(<>) : <code class="type">'a -> 'a -> bool</code></pre><div class="info">
Negation of <a href="Pervasives.html#VAL(=)"><code class="code">(=)</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(<)"></a>(<) : <code class="type">'a -> 'a -> bool</code></pre><div class="info">
See <a href="Pervasives.html#VAL(>=)"><code class="code">(>=)</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(>)"></a>(>) : <code class="type">'a -> 'a -> bool</code></pre><div class="info">
See <a href="Pervasives.html#VAL(>=)"><code class="code">(>=)</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(<=)"></a>(<=) : <code class="type">'a -> 'a -> bool</code></pre><div class="info">
See <a href="Pervasives.html#VAL(>=)"><code class="code">(>=)</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(>=)"></a>(>=) : <code class="type">'a -> 'a -> bool</code></pre><div class="info">
Structural ordering functions. These functions coincide with
the usual orderings over integers, characters, strings
and floating-point numbers, and extend them to a
total ordering over all types.
The ordering is compatible with <code class="code">(=)</code>. As in the case
of <code class="code">(=)</code>, mutable structures are compared by contents.
Comparison between functional values raises <code class="code"><span class="constructor">Invalid_argument</span></code>.
Comparison between cyclic structures does not terminate.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALcompare"></a>compare : <code class="type">'a -> 'a -> int</code></pre><div class="info">
<code class="code">compare x y</code> returns <code class="code">0</code> if <code class="code">x</code> is equal to <code class="code">y</code>,
a negative integer if <code class="code">x</code> is less than <code class="code">y</code>, and a positive integer
if <code class="code">x</code> is greater than <code class="code">y</code>. The ordering implemented by <code class="code">compare</code>
is compatible with the comparison predicates <code class="code">=</code>, <code class="code"><</code> and <code class="code">></code>
defined above, with one difference on the treatment of the float value
<a href="Pervasives.html#VALnan"><code class="code">nan</code></a>. Namely, the comparison predicates treat <code class="code">nan</code>
as different from any other float value, including itself;
while <code class="code">compare</code> treats <code class="code">nan</code> as equal to itself and less than any
other float value. This treatment of <code class="code">nan</code> ensures that <code class="code">compare</code>
defines a total ordering relation.
<p>
<code class="code">compare</code> applied to functional values may raise <code class="code"><span class="constructor">Invalid_argument</span></code>.
<code class="code">compare</code> applied to cyclic structures may not terminate.
<p>
The <code class="code">compare</code> function can be used as the comparison function
required by the <a href="Set.Make.html"><code class="code"><span class="constructor">Set</span>.<span class="constructor">Make</span></code></a> and <a href="Map.Make.html"><code class="code"><span class="constructor">Map</span>.<span class="constructor">Make</span></code></a> functors, as well as
the <a href="List.html#VALsort"><code class="code"><span class="constructor">List</span>.sort</code></a> and <a href="Array.html#VALsort"><code class="code"><span class="constructor">Array</span>.sort</code></a> functions.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmin"></a>min : <code class="type">'a -> 'a -> 'a</code></pre><div class="info">
Return the smaller of the two arguments.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmax"></a>max : <code class="type">'a -> 'a -> 'a</code></pre><div class="info">
Return the greater of the two arguments.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(==)"></a>(==) : <code class="type">'a -> 'a -> bool</code></pre><div class="info">
<code class="code">e1 == e2</code> tests for physical equality of <code class="code">e1</code> and <code class="code">e2</code>.
On integers and characters, physical equality is identical to structural
equality. On mutable structures, <code class="code">e1 == e2</code> is true if and only if
physical modification of <code class="code">e1</code> also affects <code class="code">e2</code>.
On non-mutable structures, the behavior of <code class="code">(==)</code> is
implementation-dependent; however, it is guaranteed that
<code class="code">e1 == e2</code> implies <code class="code">compare e1 e2 = 0</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(!=)"></a>(!=) : <code class="type">'a -> 'a -> bool</code></pre><div class="info">
Negation of <a href="Pervasives.html#VAL(==)"><code class="code">(==)</code></a>.<br>
</div>
<br>
<a name="6_Booleanoperations"></a>
<h6>Boolean operations</h6><br>
<pre><span class="keyword">val</span> <a name="VALnot"></a>not : <code class="type">bool -> bool</code></pre><div class="info">
The boolean negation.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(&&)"></a>(&&) : <code class="type">bool -> bool -> bool</code></pre><div class="info">
The boolean ``and''. Evaluation is sequential, left-to-right:
in <code class="code">e1 <span class="keywordsign">&&</span> e2</code>, <code class="code">e1</code> is evaluated first, and if it returns <code class="code"><span class="keyword">false</span></code>,
<code class="code">e2</code> is not evaluated at all.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(&)"></a>(&) : <code class="type">bool -> bool -> bool</code></pre><div class="info">
<span class="warning">Deprecated.</span><a href="Pervasives.html#VAL(&&)"><code class="code">(<span class="keywordsign">&&</span>)</code></a> should be used instead.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(||)"></a>(||) : <code class="type">bool -> bool -> bool</code></pre><div class="info">
The boolean ``or''. Evaluation is sequential, left-to-right:
in <code class="code">e1 <span class="keywordsign">||</span> e2</code>, <code class="code">e1</code> is evaluated first, and if it returns <code class="code"><span class="keyword">true</span></code>,
<code class="code">e2</code> is not evaluated at all.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALor"></a>or : <code class="type">bool -> bool -> bool</code></pre><div class="info">
<span class="warning">Deprecated.</span><a href="Pervasives.html#VAL(||)"><code class="code">(<span class="keywordsign">||</span>)</code></a> should be used instead.<br>
</div>
<br>
<a name="6_Integerarithmetic"></a>
<h6>Integer arithmetic</h6><br>
<br>
Integers are 31 bits wide (or 63 bits on 64-bit processors).
All operations are taken modulo 2<sup class="superscript">31</sup> (or 2<sup class="superscript">63</sup>).
They do not fail on overflow.<br>
<pre><span class="keyword">val</span> <a name="VAL(~-)"></a>(~-) : <code class="type">int -> int</code></pre><div class="info">
Unary negation. You can also write <code class="code">-e</code> instead of <code class="code"><span class="keywordsign">~-</span>e</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALsucc"></a>succ : <code class="type">int -> int</code></pre><div class="info">
<code class="code">succ x</code> is <code class="code">x+1</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALpred"></a>pred : <code class="type">int -> int</code></pre><div class="info">
<code class="code">pred x</code> is <code class="code">x-1</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(+)"></a>(+) : <code class="type">int -> int -> int</code></pre><div class="info">
Integer addition.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(-)"></a>(-) : <code class="type">int -> int -> int</code></pre><div class="info">
Integer subtraction.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(*)"></a>(*) : <code class="type">int -> int -> int</code></pre><div class="info">
Integer multiplication.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(/)"></a>(/) : <code class="type">int -> int -> int</code></pre><div class="info">
Integer division.
Raise <code class="code"><span class="constructor">Division_by_zero</span></code> if the second argument is 0.
Integer division rounds the real quotient of its arguments towards zero.
More precisely, if <code class="code">x >= 0</code> and <code class="code">y > 0</code>, <code class="code">x / y</code> is the greatest integer
less than or equal to the real quotient of <code class="code">x</code> by <code class="code">y</code>. Moreover,
<code class="code">(-x) / y = x / (-y) = -(x / y)</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmod"></a>mod : <code class="type">int -> int -> int</code></pre><div class="info">
Integer remainder. If <code class="code">y</code> is not zero, the result
of <code class="code">x <span class="keyword">mod</span> y</code> satisfies the following properties:
<code class="code">x = (x / y) * y + x <span class="keyword">mod</span> y</code> and
<code class="code">abs(x <span class="keyword">mod</span> y) <= abs(y)-1</code>.
If <code class="code">y = 0</code>, <code class="code">x <span class="keyword">mod</span> y</code> raises <code class="code"><span class="constructor">Division_by_zero</span></code>.
Notice that <code class="code">x <span class="keyword">mod</span> y</code> is negative if and only if <code class="code">x < 0</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALabs"></a>abs : <code class="type">int -> int</code></pre><div class="info">
Return the absolute value of the argument.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmax_int"></a>max_int : <code class="type">int</code></pre><div class="info">
The greatest representable integer.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmin_int"></a>min_int : <code class="type">int</code></pre><div class="info">
The smallest representable integer.<br>
</div>
<br>
<a name="7_Bitwiseoperations"></a>
<div class="h7">Bitwise operations</div><br>
<pre><span class="keyword">val</span> <a name="VALland"></a>land : <code class="type">int -> int -> int</code></pre><div class="info">
Bitwise logical and.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALlor"></a>lor : <code class="type">int -> int -> int</code></pre><div class="info">
Bitwise logical or.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALlxor"></a>lxor : <code class="type">int -> int -> int</code></pre><div class="info">
Bitwise logical exclusive or.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALlnot"></a>lnot : <code class="type">int -> int</code></pre><div class="info">
Bitwise logical negation.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALlsl"></a>lsl : <code class="type">int -> int -> int</code></pre><div class="info">
<code class="code">n <span class="keyword">lsl</span> m</code> shifts <code class="code">n</code> to the left by <code class="code">m</code> bits.
The result is unspecified if <code class="code">m < 0</code> or <code class="code">m >= bitsize</code>,
where <code class="code">bitsize</code> is <code class="code">32</code> on a 32-bit platform and
<code class="code">64</code> on a 64-bit platform.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALlsr"></a>lsr : <code class="type">int -> int -> int</code></pre><div class="info">
<code class="code">n <span class="keyword">lsr</span> m</code> shifts <code class="code">n</code> to the right by <code class="code">m</code> bits.
This is a logical shift: zeroes are inserted regardless of
the sign of <code class="code">n</code>.
The result is unspecified if <code class="code">m < 0</code> or <code class="code">m >= bitsize</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALasr"></a>asr : <code class="type">int -> int -> int</code></pre><div class="info">
<code class="code">n <span class="keyword">asr</span> m</code> shifts <code class="code">n</code> to the right by <code class="code">m</code> bits.
This is an arithmetic shift: the sign bit of <code class="code">n</code> is replicated.
The result is unspecified if <code class="code">m < 0</code> or <code class="code">m >= bitsize</code>.<br>
</div>
<br>
<a name="6_Floatingpointarithmetic"></a>
<h6>Floating-point arithmetic</h6>
<p>
Caml's floating-point numbers follow the
IEEE 754 standard, using double precision (64 bits) numbers.
Floating-point operations never raise an exception on overflow,
underflow, division by zero, etc. Instead, special IEEE numbers
are returned as appropriate, such as <code class="code">infinity</code> for <code class="code">1.0 /. 0.0</code>,
<code class="code">neg_infinity</code> for <code class="code">-1.0 /. 0.0</code>, and <code class="code">nan</code> (``not a number'')
for <code class="code">0.0 /. 0.0</code>. These special numbers then propagate through
floating-point computations as expected: for instance,
<code class="code">1.0 /. infinity</code> is <code class="code">0.0</code>, and any operation with <code class="code">nan</code> as
argument returns <code class="code">nan</code> as result.<br>
<pre><span class="keyword">val</span> <a name="VAL(~-.)"></a>(~-.) : <code class="type">float -> float</code></pre><div class="info">
Unary negation. You can also write <code class="code">-.e</code> instead of <code class="code"><span class="keywordsign">~-.</span>e</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(+.)"></a>(+.) : <code class="type">float -> float -> float</code></pre><div class="info">
Floating-point addition<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(-.)"></a>(-.) : <code class="type">float -> float -> float</code></pre><div class="info">
Floating-point subtraction<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(*.)"></a>(*.) : <code class="type">float -> float -> float</code></pre><div class="info">
Floating-point multiplication<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(/.)"></a>(/.) : <code class="type">float -> float -> float</code></pre><div class="info">
Floating-point division.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(**)"></a>(**) : <code class="type">float -> float -> float</code></pre><div class="info">
Exponentiation<br>
</div>
<pre><span class="keyword">val</span> <a name="VALsqrt"></a>sqrt : <code class="type">float -> float</code></pre><div class="info">
Square root<br>
</div>
<pre><span class="keyword">val</span> <a name="VALexp"></a>exp : <code class="type">float -> float</code></pre><div class="info">
Exponential.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALlog"></a>log : <code class="type">float -> float</code></pre><div class="info">
Natural logarithm.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALlog10"></a>log10 : <code class="type">float -> float</code></pre><div class="info">
Base 10 logarithm.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALcos"></a>cos : <code class="type">float -> float</code></pre><div class="info">
See <a href="Pervasives.html#VALatan2"><code class="code">atan2</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALsin"></a>sin : <code class="type">float -> float</code></pre><div class="info">
See <a href="Pervasives.html#VALatan2"><code class="code">atan2</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALtan"></a>tan : <code class="type">float -> float</code></pre><div class="info">
See <a href="Pervasives.html#VALatan2"><code class="code">atan2</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALacos"></a>acos : <code class="type">float -> float</code></pre><div class="info">
See <a href="Pervasives.html#VALatan2"><code class="code">atan2</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALasin"></a>asin : <code class="type">float -> float</code></pre><div class="info">
See <a href="Pervasives.html#VALatan2"><code class="code">atan2</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALatan"></a>atan : <code class="type">float -> float</code></pre><div class="info">
See <a href="Pervasives.html#VALatan2"><code class="code">atan2</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALatan2"></a>atan2 : <code class="type">float -> float -> float</code></pre><div class="info">
The usual trigonometric functions.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALcosh"></a>cosh : <code class="type">float -> float</code></pre><div class="info">
See <a href="Pervasives.html#VALtanh"><code class="code">tanh</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALsinh"></a>sinh : <code class="type">float -> float</code></pre><div class="info">
See <a href="Pervasives.html#VALtanh"><code class="code">tanh</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALtanh"></a>tanh : <code class="type">float -> float</code></pre><div class="info">
The usual hyperbolic trigonometric functions.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALceil"></a>ceil : <code class="type">float -> float</code></pre><div class="info">
See <a href="Pervasives.html#VALfloor"><code class="code">floor</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfloor"></a>floor : <code class="type">float -> float</code></pre><div class="info">
Round the given float to an integer value.
<code class="code">floor f</code> returns the greatest integer value less than or
equal to <code class="code">f</code>.
<code class="code">ceil f</code> returns the least integer value greater than or
equal to <code class="code">f</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALabs_float"></a>abs_float : <code class="type">float -> float</code></pre><div class="info">
Return the absolute value of the argument.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmod_float"></a>mod_float : <code class="type">float -> float -> float</code></pre><div class="info">
<code class="code">mod_float a b</code> returns the remainder of <code class="code">a</code> with respect to
<code class="code">b</code>. The returned value is <code class="code">a -. n *. b</code>, where <code class="code">n</code>
is the quotient <code class="code">a /. b</code> rounded towards zero to an integer.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfrexp"></a>frexp : <code class="type">float -> float * int</code></pre><div class="info">
<code class="code">frexp f</code> returns the pair of the significant
and the exponent of <code class="code">f</code>. When <code class="code">f</code> is zero, the
significant <code class="code">x</code> and the exponent <code class="code">n</code> of <code class="code">f</code> are equal to
zero. When <code class="code">f</code> is non-zero, they are defined by
<code class="code">f = x *. 2 ** n</code> and <code class="code">0.5 <= x < 1.0</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALldexp"></a>ldexp : <code class="type">float -> int -> float</code></pre><div class="info">
<code class="code">ldexp x n</code> returns <code class="code">x *. 2 ** n</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmodf"></a>modf : <code class="type">float -> float * float</code></pre><div class="info">
<code class="code">modf f</code> returns the pair of the fractional and integral
part of <code class="code">f</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfloat"></a>float : <code class="type">int -> float</code></pre><div class="info">
Same as <a href="Pervasives.html#VALfloat_of_int"><code class="code">float_of_int</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfloat_of_int"></a>float_of_int : <code class="type">int -> float</code></pre><div class="info">
Convert an integer to floating-point.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALtruncate"></a>truncate : <code class="type">float -> int</code></pre><div class="info">
Same as <a href="Pervasives.html#VALint_of_float"><code class="code">int_of_float</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALint_of_float"></a>int_of_float : <code class="type">float -> int</code></pre><div class="info">
Truncate the given floating-point number to an integer.
The result is unspecified if it falls outside the
range of representable integers.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALinfinity"></a>infinity : <code class="type">float</code></pre><div class="info">
Positive infinity.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALneg_infinity"></a>neg_infinity : <code class="type">float</code></pre><div class="info">
Negative infinity.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALnan"></a>nan : <code class="type">float</code></pre><div class="info">
A special floating-point value denoting the result of an
undefined operation such as <code class="code">0.0 /. 0.0</code>. Stands for
``not a number''. Any floating-point operation with <code class="code">nan</code> as
argument returns <code class="code">nan</code> as result. As for floating-point comparisons,
<code class="code">=</code>, <code class="code"><</code>, <code class="code"><=</code>, <code class="code">></code> and <code class="code">>=</code> return <code class="code"><span class="keyword">false</span></code> and <code class="code"><></code> returns <code class="code"><span class="keyword">true</span></code>
if one or both of their arguments is <code class="code">nan</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmax_float"></a>max_float : <code class="type">float</code></pre><div class="info">
The largest positive finite value of type <code class="code">float</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmin_float"></a>min_float : <code class="type">float</code></pre><div class="info">
The smallest positive, non-zero, non-denormalized value of type <code class="code">float</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALepsilon_float"></a>epsilon_float : <code class="type">float</code></pre><div class="info">
The smallest positive float <code class="code">x</code> such that <code class="code">1.0 +. x <> 1.0</code>.<br>
</div>
<br><code><span class="keyword">type</span> <a name="TYPEfpclass"></a><code class="type"></code>fpclass = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">FP_normal</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Normal number, none of the below</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">FP_subnormal</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Number very close to 0.0, has reduced precision</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">FP_zero</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Number is 0.0 or -0.0</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">FP_infinite</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Number is positive or negative infinity</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">FP_nan</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Not a number: result of an undefined operation</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
<div class="info">
The five classes of floating-point numbers, as determined by
the <a href="Pervasives.html#VALclassify_float"><code class="code">classify_float</code></a> function.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALclassify_float"></a>classify_float : <code class="type">float -> <a href="Pervasives.html#TYPEfpclass">fpclass</a></code></pre><div class="info">
Return the class of the given floating-point number:
normal, subnormal, zero, infinite, or not a number.<br>
</div>
<br>
<a name="6_Stringoperations"></a>
<h6>String operations</h6>
<p>
More string operations are provided in module <a href="String.html"><code class="code"><span class="constructor">String</span></code></a>.<br>
<pre><span class="keyword">val</span> <a name="VAL(^)"></a>(^) : <code class="type">string -> string -> string</code></pre><div class="info">
String concatenation.<br>
</div>
<br>
<a name="6_Characteroperations"></a>
<h6>Character operations</h6>
<p>
More character operations are provided in module <a href="Char.html"><code class="code"><span class="constructor">Char</span></code></a>.<br>
<pre><span class="keyword">val</span> <a name="VALint_of_char"></a>int_of_char : <code class="type">char -> int</code></pre><div class="info">
Return the ASCII code of the argument.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALchar_of_int"></a>char_of_int : <code class="type">int -> char</code></pre><div class="info">
Return the character with the given ASCII code.
Raise <code class="code"><span class="constructor">Invalid_argument</span> <span class="string">"char_of_int"</span></code> if the argument is
outside the range 0--255.<br>
</div>
<br>
<a name="6_Unitoperations"></a>
<h6>Unit operations</h6><br>
<pre><span class="keyword">val</span> <a name="VALignore"></a>ignore : <code class="type">'a -> unit</code></pre><div class="info">
Discard the value of its argument and return <code class="code">()</code>.
For instance, <code class="code">ignore(f x)</code> discards the result of
the side-effecting function <code class="code">f</code>. It is equivalent to
<code class="code">f x; ()</code>, except that the latter may generate a
compiler warning; writing <code class="code">ignore(f x)</code> instead
avoids the warning.<br>
</div>
<br>
<a name="6_Stringconversionfunctions"></a>
<h6>String conversion functions</h6><br>
<pre><span class="keyword">val</span> <a name="VALstring_of_bool"></a>string_of_bool : <code class="type">bool -> string</code></pre><div class="info">
Return the string representation of a boolean.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALbool_of_string"></a>bool_of_string : <code class="type">string -> bool</code></pre><div class="info">
Convert the given string to a boolean.
Raise <code class="code"><span class="constructor">Invalid_argument</span> <span class="string">"bool_of_string"</span></code> if the string is not
<code class="code"><span class="string">"true"</span></code> or <code class="code"><span class="string">"false"</span></code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALstring_of_int"></a>string_of_int : <code class="type">int -> string</code></pre><div class="info">
Return the string representation of an integer, in decimal.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALint_of_string"></a>int_of_string : <code class="type">string -> int</code></pre><div class="info">
Convert the given string to an integer.
The string is read in decimal (by default) or in hexadecimal (if it
begins with <code class="code">0x</code> or <code class="code">0<span class="constructor">X</span></code>), octal (if it begins with <code class="code">0o</code> or <code class="code">0<span class="constructor">O</span></code>),
or binary (if it begins with <code class="code">0b</code> or <code class="code">0<span class="constructor">B</span></code>).
Raise <code class="code"><span class="constructor">Failure</span> <span class="string">"int_of_string"</span></code> if the given string is not
a valid representation of an integer, or if the integer represented
exceeds the range of integers representable in type <code class="code">int</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALstring_of_float"></a>string_of_float : <code class="type">float -> string</code></pre><div class="info">
Return the string representation of a floating-point number.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfloat_of_string"></a>float_of_string : <code class="type">string -> float</code></pre><div class="info">
Convert the given string to a float. Raise <code class="code"><span class="constructor">Failure</span> <span class="string">"float_of_string"</span></code>
if the given string is not a valid representation of a float.<br>
</div>
<br>
<a name="6_Pairoperations"></a>
<h6>Pair operations</h6><br>
<pre><span class="keyword">val</span> <a name="VALfst"></a>fst : <code class="type">'a * 'b -> 'a</code></pre><div class="info">
Return the first component of a pair.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALsnd"></a>snd : <code class="type">'a * 'b -> 'b</code></pre><div class="info">
Return the second component of a pair.<br>
</div>
<br>
<a name="6_Listoperations"></a>
<h6>List operations</h6>
<p>
More list operations are provided in module <a href="List.html"><code class="code"><span class="constructor">List</span></code></a>.<br>
<pre><span class="keyword">val</span> <a name="VAL(@)"></a>(@) : <code class="type">'a list -> 'a list -> 'a list</code></pre><div class="info">
List concatenation.<br>
</div>
<br>
<a name="6_Inputoutput"></a>
<h6>Input/output</h6><br>
<pre><span class="keyword">type</span> <a name="TYPEin_channel"></a><code class="type"></code>in_channel </pre>
<div class="info">
The type of input channel.<br>
</div>
<pre><span class="keyword">type</span> <a name="TYPEout_channel"></a><code class="type"></code>out_channel </pre>
<div class="info">
The type of output channel.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALstdin"></a>stdin : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a></code></pre><div class="info">
The standard input for the process.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALstdout"></a>stdout : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a></code></pre><div class="info">
The standard output for the process.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALstderr"></a>stderr : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a></code></pre><div class="info">
The standard error ouput for the process.<br>
</div>
<br>
<a name="7_Outputfunctionsonstandardoutput"></a>
<div class="h7">Output functions on standard output</div><br>
<pre><span class="keyword">val</span> <a name="VALprint_char"></a>print_char : <code class="type">char -> unit</code></pre><div class="info">
Print a character on standard output.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprint_string"></a>print_string : <code class="type">string -> unit</code></pre><div class="info">
Print a string on standard output.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprint_int"></a>print_int : <code class="type">int -> unit</code></pre><div class="info">
Print an integer, in decimal, on standard output.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprint_float"></a>print_float : <code class="type">float -> unit</code></pre><div class="info">
Print a floating-point number, in decimal, on standard output.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprint_endline"></a>print_endline : <code class="type">string -> unit</code></pre><div class="info">
Print a string, followed by a newline character, on
standard output and flush standard output.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprint_newline"></a>print_newline : <code class="type">unit -> unit</code></pre><div class="info">
Print a newline character on standard output, and flush
standard output. This can be used to simulate line
buffering of standard output.<br>
</div>
<br>
<a name="7_Outputfunctionsonstandarderror"></a>
<div class="h7">Output functions on standard error</div><br>
<pre><span class="keyword">val</span> <a name="VALprerr_char"></a>prerr_char : <code class="type">char -> unit</code></pre><div class="info">
Print a character on standard error.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprerr_string"></a>prerr_string : <code class="type">string -> unit</code></pre><div class="info">
Print a string on standard error.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprerr_int"></a>prerr_int : <code class="type">int -> unit</code></pre><div class="info">
Print an integer, in decimal, on standard error.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprerr_float"></a>prerr_float : <code class="type">float -> unit</code></pre><div class="info">
Print a floating-point number, in decimal, on standard error.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprerr_endline"></a>prerr_endline : <code class="type">string -> unit</code></pre><div class="info">
Print a string, followed by a newline character on standard error
and flush standard error.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprerr_newline"></a>prerr_newline : <code class="type">unit -> unit</code></pre><div class="info">
Print a newline character on standard error, and flush
standard error.<br>
</div>
<br>
<a name="7_Inputfunctionsonstandardinput"></a>
<div class="h7">Input functions on standard input</div><br>
<pre><span class="keyword">val</span> <a name="VALread_line"></a>read_line : <code class="type">unit -> string</code></pre><div class="info">
Flush standard output, then read characters from standard input
until a newline character is encountered. Return the string of
all characters read, without the newline character at the end.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALread_int"></a>read_int : <code class="type">unit -> int</code></pre><div class="info">
Flush standard output, then read one line from standard input
and convert it to an integer. Raise <code class="code"><span class="constructor">Failure</span> <span class="string">"int_of_string"</span></code>
if the line read is not a valid representation of an integer.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALread_float"></a>read_float : <code class="type">unit -> float</code></pre><div class="info">
Flush standard output, then read one line from standard input
and convert it to a floating-point number.
The result is unspecified if the line read is not a valid
representation of a floating-point number.<br>
</div>
<br>
<a name="7_Generaloutputfunctions"></a>
<div class="h7">General output functions</div><br>
<br><code><span class="keyword">type</span> <a name="TYPEopen_flag"></a><code class="type"></code>open_flag = </code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Open_rdonly</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >open for reading.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Open_wronly</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >open for writing.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Open_append</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >open for appending: always write at end of file.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Open_creat</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >create the file if it does not exist.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Open_trunc</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >empty the file if it already exists.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Open_excl</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >fail if
<span style="background-color:yellow; color:red">Open_creat and</span>
the file already exists.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Open_binary</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >open in binary mode (no conversion).</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Open_text</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >open in text mode (may perform conversions).</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Open_nonblock</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >open in non-blocking mode.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
<div class="info">
Opening modes for <a href="Pervasives.html#VALopen_out_gen"><code class="code">open_out_gen</code></a> and
<a href="Pervasives.html#VALopen_in_gen"><code class="code">open_in_gen</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALopen_out"></a>open_out : <code class="type">string -> <a href="Pervasives.html#TYPEout_channel">out_channel</a></code></pre><div class="info">
Open the named file for writing, and return a new output channel
on that file, positionned at the beginning of the file. The
file is truncated to zero length if it already exists. It
is created if it does not already exists.
Raise <code class="code"><span class="constructor">Sys_error</span></code> if the file could not be opened.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALopen_out_bin"></a>open_out_bin : <code class="type">string -> <a href="Pervasives.html#TYPEout_channel">out_channel</a></code></pre><div class="info">
Same as <a href="Pervasives.html#VALopen_out"><code class="code">open_out</code></a>, but the file is opened in binary mode,
so that no translation takes place during writes. On operating
systems that do not distinguish between text mode and binary
mode, this function behaves like <a href="Pervasives.html#VALopen_out"><code class="code">open_out</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALopen_out_gen"></a>open_out_gen : <code class="type"><a href="Pervasives.html#TYPEopen_flag">open_flag</a> list -> int -> string -> <a href="Pervasives.html#TYPEout_channel">out_channel</a></code></pre><div class="info">
<code class="code">open_out_gen mode perm filename</code> opens the named file for writing,
as described above. The extra argument <code class="code">mode</code>
specify the opening mode. The extra argument <code class="code">perm</code> specifies
the file permissions, in case the file must be created.
<a href="Pervasives.html#VALopen_out"><code class="code">open_out</code></a> and <a href="Pervasives.html#VALopen_out_bin"><code class="code">open_out_bin</code></a> are special
cases of this function.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALflush"></a>flush : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> unit</code></pre><div class="info">
Flush the buffer associated with the given output channel,
performing all pending writes on that channel.
Interactive programs must be careful about flushing standard
output and standard error at the right time.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALflush_all"></a>flush_all : <code class="type">unit -> unit</code></pre><div class="info">
Flush all open output channels; ignore errors.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALoutput_char"></a>output_char : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> char -> unit</code></pre><div class="info">
Write the character on the given output channel.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALoutput_string"></a>output_string : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> string -> unit</code></pre><div class="info">
Write the string on the given output channel.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALoutput"></a>output : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> string -> int -> int -> unit</code></pre><div class="info">
<code class="code">output oc buf pos len</code> writes <code class="code">len</code> characters from string <code class="code">buf</code>,
starting at offset <code class="code">pos</code>, to the given output channel <code class="code">oc</code>.
Raise <code class="code"><span class="constructor">Invalid_argument</span> <span class="string">"output"</span></code> if <code class="code">pos</code> and <code class="code">len</code> do not
designate a valid substring of <code class="code">buf</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALoutput_byte"></a>output_byte : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> int -> unit</code></pre><div class="info">
Write one 8-bit integer (as the single character with that code)
on the given output channel. The given integer is taken modulo
256.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALoutput_binary_int"></a>output_binary_int : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> int -> unit</code></pre><div class="info">
Write one integer in binary format (4 bytes, big-endian)
on the given output channel.
The given integer is taken modulo 2<sup class="superscript">32</sup>.
The only reliable way to read it back is through the
<a href="Pervasives.html#VALinput_binary_int"><code class="code">input_binary_int</code></a> function. The format is compatible across
all machines for a given version of Objective Caml.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALoutput_value"></a>output_value : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> 'a -> unit</code></pre><div class="info">
Write the representation of a structured value of any type
to a channel. Circularities and sharing inside the value
are detected and preserved. The object can be read back,
by the function <a href="Pervasives.html#VALinput_value"><code class="code">input_value</code></a>. See the description of module
<a href="Marshal.html"><code class="code"><span class="constructor">Marshal</span></code></a> for more information. <a href="Pervasives.html#VALoutput_value"><code class="code">output_value</code></a> is equivalent
to <a href="Marshal.html#VALto_channel"><code class="code"><span class="constructor">Marshal</span>.to_channel</code></a> with an empty list of flags.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALseek_out"></a>seek_out : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> int -> unit</code></pre><div class="info">
<code class="code">seek_out chan pos</code> sets the current writing position to <code class="code">pos</code>
for channel <code class="code">chan</code>. This works only for regular files. On
files of other kinds (such as terminals, pipes and sockets),
the behavior is unspecified.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALpos_out"></a>pos_out : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> int</code></pre><div class="info">
Return the current writing position for the given channel. Does
not work on channels opened with the <code class="code"><span class="constructor">Open_append</span></code> flag (returns
unspecified results).<br>
</div>
<pre><span class="keyword">val</span> <a name="VALout_channel_length"></a>out_channel_length : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> int</code></pre><div class="info">
Return the size (number of characters) of the regular file
on which the given channel is opened. If the channel is opened
on a file that is not a regular file, the result is meaningless.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALclose_out"></a>close_out : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> unit</code></pre><div class="info">
Close the given channel, flushing all buffered write operations.
Output functions raise a <code class="code"><span class="constructor">Sys_error</span></code> exception when they are
applied to a closed output channel, except <code class="code">close_out</code> and <code class="code">flush</code>,
which do nothing when applied to an already closed channel.
Note that <code class="code">close_out</code> may raise <code class="code"><span class="constructor">Sys_error</span></code> if the operating
system signals an error when flushing or closing.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALclose_out_noerr"></a>close_out_noerr : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> unit</code></pre><div class="info">
Same as <code class="code">close_out</code>, but ignore all errors.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALset_binary_mode_out"></a>set_binary_mode_out : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> bool -> unit</code></pre><div class="info">
<code class="code">set_binary_mode_out oc <span class="keyword">true</span></code> sets the channel <code class="code">oc</code> to binary
mode: no translations take place during output.
<code class="code">set_binary_mode_out oc <span class="keyword">false</span></code> sets the channel <code class="code">oc</code> to text
mode: depending on the operating system, some translations
may take place during output. For instance, under Windows,
end-of-lines will be translated from <code class="code">\n</code> to <code class="code">\r\n</code>.
This function has no effect under operating systems that
do not distinguish between text mode and binary mode.<br>
</div>
<br>
<a name="7_Generalinputfunctions"></a>
<div class="h7">General input functions</div><br>
<pre><span class="keyword">val</span> <a name="VALopen_in"></a>open_in : <code class="type">string -> <a href="Pervasives.html#TYPEin_channel">in_channel</a></code></pre><div class="info">
Open the named file for reading, and return a new input channel
on that file, positionned at the beginning of the file.
Raise <code class="code"><span class="constructor">Sys_error</span></code> if the file could not be opened.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALopen_in_bin"></a>open_in_bin : <code class="type">string -> <a href="Pervasives.html#TYPEin_channel">in_channel</a></code></pre><div class="info">
Same as <a href="Pervasives.html#VALopen_in"><code class="code">open_in</code></a>, but the file is opened in binary mode,
so that no translation takes place during reads. On operating
systems that do not distinguish between text mode and binary
mode, this function behaves like <a href="Pervasives.html#VALopen_in"><code class="code">open_in</code></a>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALopen_in_gen"></a>open_in_gen : <code class="type"><a href="Pervasives.html#TYPEopen_flag">open_flag</a> list -> int -> string -> <a href="Pervasives.html#TYPEin_channel">in_channel</a></code></pre><div class="info">
<code class="code">open_in mode perm filename</code> opens the named file for reading,
as described above. The extra arguments
<code class="code">mode</code> and <code class="code">perm</code> specify the opening mode and file permissions.
<a href="Pervasives.html#VALopen_in"><code class="code">open_in</code></a> and <a href="Pervasives.html#VALopen_in_bin"><code class="code">open_in_bin</code></a> are special
cases of this function.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALinput_char"></a>input_char : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> char</code></pre><div class="info">
Read one character from the given input channel.
Raise <code class="code"><span class="constructor">End_of_file</span></code> if there are no more characters to read.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALinput_line"></a>input_line : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> string</code></pre><div class="info">
Read characters from the given input channel, until a
newline character is encountered. Return the string of
all characters read, without the newline character at the end.
Raise <code class="code"><span class="constructor">End_of_file</span></code> if the end of the file is reached
at the beginning of line.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALinput"></a>input : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> string -> int -> int -> int</code></pre><div class="info">
<code class="code">input ic buf pos len</code> reads up to <code class="code">len</code> characters from
the given channel <code class="code">ic</code>, storing them in string <code class="code">buf</code>, starting at
character number <code class="code">pos</code>.
It returns the actual number of characters read, between 0 and
<code class="code">len</code> (inclusive).
A return value of 0 means that the end of file was reached.
A return value between 0 and <code class="code">len</code> exclusive means that
not all requested <code class="code">len</code> characters were read, either because
no more characters were available at that time, or because
the implementation found it convenient to do a partial read;
<code class="code">input</code> must be called again to read the remaining characters,
if desired. (See also <a href="Pervasives.html#VALreally_input"><code class="code">really_input</code></a> for reading
exactly <code class="code">len</code> characters.)
Exception <code class="code"><span class="constructor">Invalid_argument</span> <span class="string">"input"</span></code> is raised if <code class="code">pos</code> and <code class="code">len</code>
do not designate a valid substring of <code class="code">buf</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALreally_input"></a>really_input : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> string -> int -> int -> unit</code></pre><div class="info">
<code class="code">really_input ic buf pos len</code> reads <code class="code">len</code> characters from channel <code class="code">ic</code>,
storing them in string <code class="code">buf</code>, starting at character number <code class="code">pos</code>.
Raise <code class="code"><span class="constructor">End_of_file</span></code> if the end of file is reached before <code class="code">len</code>
characters have been read.
Raise <code class="code"><span class="constructor">Invalid_argument</span> <span class="string">"really_input"</span></code> if
<code class="code">pos</code> and <code class="code">len</code> do not designate a valid substring of <code class="code">buf</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALinput_byte"></a>input_byte : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> int</code></pre><div class="info">
Same as <a href="Pervasives.html#VALinput_char"><code class="code">input_char</code></a>, but return the 8-bit integer representing
the character.
Raise <code class="code"><span class="constructor">End_of_file</span></code> if an end of file was reached.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALinput_binary_int"></a>input_binary_int : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> int</code></pre><div class="info">
Read an integer encoded in binary format (4 bytes, big-endian)
from the given input channel. See <a href="Pervasives.html#VALoutput_binary_int"><code class="code">output_binary_int</code></a>.
Raise <code class="code"><span class="constructor">End_of_file</span></code> if an end of file was reached while reading the
integer.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALinput_value"></a>input_value : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> 'a</code></pre><div class="info">
Read the representation of a structured value, as produced
by <a href="Pervasives.html#VALoutput_value"><code class="code">output_value</code></a>, and return the corresponding value.
This function is identical to <a href="Marshal.html#VALfrom_channel"><code class="code"><span class="constructor">Marshal</span>.from_channel</code></a>;
see the description of module <a href="Marshal.html"><code class="code"><span class="constructor">Marshal</span></code></a> for more information,
in particular concerning the lack of type safety.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALseek_in"></a>seek_in : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> int -> unit</code></pre><div class="info">
<code class="code">seek_in chan pos</code> sets the current reading position to <code class="code">pos</code>
for channel <code class="code">chan</code>. This works only for regular files. On
files of other kinds, the behavior is unspecified.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALpos_in"></a>pos_in : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> int</code></pre><div class="info">
Return the current reading position for the given channel.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALin_channel_length"></a>in_channel_length : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> int</code></pre><div class="info">
Return the size (number of characters) of the regular file
on which the given channel is opened. If the channel is opened
on a file that is not a regular file, the result is meaningless.
The returned size does not take into account the end-of-line
translations that can be performed when reading from a channel
opened in text mode.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALclose_in"></a>close_in : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> unit</code></pre><div class="info">
Close the given channel. Input functions raise a <code class="code"><span class="constructor">Sys_error</span></code>
exception when they are applied to a closed input channel,
except <code class="code">close_in</code>, which does nothing when applied to an already
closed channel. Note that <code class="code">close_in</code> may raise <code class="code"><span class="constructor">Sys_error</span></code> if
the operating system signals an error.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALclose_in_noerr"></a>close_in_noerr : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> unit</code></pre><div class="info">
Same as <code class="code">close_in</code>, but ignore all errors.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALset_binary_mode_in"></a>set_binary_mode_in : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> bool -> unit</code></pre><div class="info">
<code class="code">set_binary_mode_in ic <span class="keyword">true</span></code> sets the channel <code class="code">ic</code> to binary
mode: no translations take place during input.
<code class="code">set_binary_mode_out ic <span class="keyword">false</span></code> sets the channel <code class="code">ic</code> to text
mode: depending on the operating system, some translations
may take place during input. For instance, under Windows,
end-of-lines will be translated from <code class="code">\r\n</code> to <code class="code">\n</code>.
This function has no effect under operating systems that
do not distinguish between text mode and binary mode.<br>
</div>
<br>
<a name="7_Operationsonlargefiles"></a>
<div class="h7">Operations on large files</div><br>
<pre><span class="keyword">module</span> <a href="Pervasives.LargeFile.html">LargeFile</a>: <code class="code"><span class="keyword">sig</span></code> <a href="Pervasives.LargeFile.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
Operations on large files.
</div>
<br>
<a name="6_References"></a>
<h6>References</h6><br>
<br><code><span class="keyword">type</span> <a name="TYPEref"></a><code class="type">'a</code> ref = {</code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span>contents : <code class="type">'a</code>;</code></td>
</tr></table>
}
<div class="info">
The type of references (mutable indirection cells) containing
a value of type <code class="code"><span class="keywordsign">'</span>a</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALref"></a>ref : <code class="type">'a -> 'a <a href="Pervasives.html#TYPEref">ref</a></code></pre><div class="info">
Return a fresh reference containing the given value.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(!)"></a>(!) : <code class="type">'a <a href="Pervasives.html#TYPEref">ref</a> -> 'a</code></pre><div class="info">
<code class="code">!r</code> returns the current contents of reference <code class="code">r</code>.
Equivalent to <code class="code"><span class="keyword">fun</span> r <span class="keywordsign">-></span> r.contents</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(:=)"></a>(:=) : <code class="type">'a <a href="Pervasives.html#TYPEref">ref</a> -> 'a -> unit</code></pre><div class="info">
<code class="code">r := a</code> stores the value of <code class="code">a</code> in reference <code class="code">r</code>.
Equivalent to <code class="code"><span class="keyword">fun</span> r v <span class="keywordsign">-></span> r.contents <- v</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALincr"></a>incr : <code class="type">int <a href="Pervasives.html#TYPEref">ref</a> -> unit</code></pre><div class="info">
Increment the integer contained in the given reference.
Equivalent to <code class="code"><span class="keyword">fun</span> r <span class="keywordsign">-></span> r := succ !r</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALdecr"></a>decr : <code class="type">int <a href="Pervasives.html#TYPEref">ref</a> -> unit</code></pre><div class="info">
Decrement the integer contained in the given reference.
Equivalent to <code class="code"><span class="keyword">fun</span> r <span class="keywordsign">-></span> r := pred !r</code>.<br>
</div>
<br>
<a name="6_Operationsonformatstrings"></a>
<h6>Operations on format strings</h6><br>
<br>
See modules <a href="Printf.html"><code class="code"><span class="constructor">Printf</span></code></a> and <a href="Scanf.html"><code class="code"><span class="constructor">Scanf</span></code></a> for more operations on
format strings.<br>
<pre><span class="keyword">type</span> <a name="TYPEformat"></a><code class="type">('a, 'b, 'c)</code> format = <code class="type">('a, 'b, 'c, 'c) format4</code> </pre>
<div class="info">
Simplified type for format strings, included for backward compatibility
with earlier releases of Objective Caml.
<code class="code"><span class="keywordsign">'</span>a</code> is the type of the parameters of the format,
<code class="code"><span class="keywordsign">'</span>c</code> is the result type for the "printf"-style function,
and <code class="code"><span class="keywordsign">'</span>b</code> is the type of the first argument given to
<code class="code">%a</code> and <code class="code">%t</code> printing functions.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALstring_of_format"></a>string_of_format : <code class="type">('a, 'b, 'c, 'd) format4 -> string</code></pre><div class="info">
Converts a format string into a string.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALformat_of_string"></a>format_of_string : <code class="type">('a, 'b, 'c, 'd) format4 -> ('a, 'b, 'c, 'd) format4</code></pre><div class="info">
<code class="code">format_of_string s</code> returns a format string read from the string
literal <code class="code">s</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(^^)"></a>(^^) : <code class="type">('a, 'b, 'c, 'd) format4 -><br> ('d, 'b, 'c, 'e) format4 -> ('a, 'b, 'c, 'e) format4</code></pre><div class="info">
<code class="code">f1 ^^ f2</code> catenates formats <code class="code">f1</code> and <code class="code">f2</code>. The result is a format
that accepts arguments from <code class="code">f1</code>, then arguments from <code class="code">f2</code>.<br>
</div>
<br>
<a name="6_Programtermination"></a>
<h6>Program termination</h6><br>
<pre><span class="keyword">val</span> <a name="VALexit"></a>exit : <code class="type">int -> 'a</code></pre><div class="info">
Terminate the process, returning the given status code
to the operating system: usually 0 to indicate no errors,
and a small positive integer to indicate failure.
All open output channels are flushed with flush_all.
An implicit <code class="code">exit 0</code> is performed each time a program
terminates normally. An implicit <code class="code">exit 2</code> is performed if the program
terminates early because of an uncaught exception.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALat_exit"></a>at_exit : <code class="type">(unit -> unit) -> unit</code></pre><div class="info">
Register the given function to be called at program
termination time. The functions registered with <code class="code">at_exit</code>
will be called when the program executes <a href="Pervasives.html#VALexit"><code class="code">exit</code></a>,
or terminates, either normally or because of an uncaught exception.
The functions are called in ``last in, first out'' order:
the function most recently added with <code class="code">at_exit</code> is called first.<br>
</div>
</body></html>
|