File: revsynt.html

package info (click to toggle)
camlp5 6.06-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 7,428 kB
  • sloc: ml: 77,055; sh: 1,417; makefile: 1,211
file content (928 lines) | stat: -rw-r--r-- 27,505 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <!-- $Id: revsynt.html,v 6.3 2012-01-09 14:22:20 deraugla Exp $ -->
  <!-- Copyright (c) INRIA 2007-2012 -->
  <title>revised syntax</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <link rel="stylesheet" type="text/css" href="styles/base.css"
        title="Normal" />
</head>
<body>

<div id="menu">
</div>

<div id="content">

<h1 class="top">The revised syntax</h1>

<p>The revised syntax is an alternative syntax of OCaml. It is close
  to the normal syntax. We present here only the differences between
  the two syntaxes.</p>

<p>Notice that there is a simple way to know how the normal syntax is
  written in revised syntax: write the code in a file "foo.ml" in
  normal syntax and type, in a shell:</p>

<pre>
  camlp5o pr_r.cmo pr_rp.cmo foo.ml
</pre>

<p>And, conversely, how a file "bar.ml" written in revised syntax is
  displayed in normal syntax:</p>

<pre>
  camlp5r pr_o.cmo pr_op.cmo bar.ml
</pre>

<p>Even simpler, without creating a file:</p>

<pre>
  camlp5o pr_r.cmo pr_op.cmo -impl -
  ... type in normal syntax ...
  ... type control-D ...
  camlp5r pr_o.cmo pr_rp.cmo -impl -
  ... type in revised syntax ...
  ... type control-D ...
</pre>

<div id="tableofcontents">
</div>

<h2>Lexing</h2>

<ul>
  <li>The character quote (<tt>'</tt>) can be written without backslash:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>'\''</tt></td>
        <td><tt>'''</tt></td>
      </tr>
    </table>
  </li>
</ul>

<h2>Modules, Structure and Signature items</h2>

<ul>
  <li>Structure and signature items always end with a single semicolon
    which is required.</li>

  <li>In structures, the declaration of a value is introduced by the
    keyword "value", instead of "let":
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>let x = 42;;</tt></td>
        <td><tt>value x = 42;</tt></td>
      </tr>
      <tr>
        <td><tt>let x = 42 in x + 7;;</tt></td>
        <td><tt>let x = 42 in x + 7;</tt></td>
      </tr>
    </table>
  </li>

  <li>In signatures, the declaration of a value is also introduced by
    the keyword "value", instead of "val":
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>val x : int;;</tt></td>
        <td><tt>value x : int;</tt></td>
      </tr>
    </table>
  </li>

  <li>In signatures, abstract module types are represented by a quote
    and an (any) identifier:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>module type MT;;</tt></td>
        <td><tt>module type MT = 'a;</tt></td>
      </tr>
    </table>
  </li>

  <li>Functor application uses currying. Parentheses are not
    required for the parameters:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>type t = Set.Make(M).t;;</tt></td>
        <td><tt>type t = (Set.Make M).t;</tt></td>
      </tr>
      <tr>
        <td><tt>module M = Mod.Make (M1) (M2);;</tt></td>
        <td><tt>module M = Mod.Make M1 M2;</tt></td>
      </tr>
    </table>
  </li>

  <li>It is possible to group several declarations together either in
    an interface or in an implementation by enclosing them between
    "declare" and "end" (this is useful when using syntax extensions
    to generate several declarations from one). Example in an
    interface:
<pre>
  declare
    type foo = [ Foo of int | Bar ];
    value f : foo -> int;
  end;
</pre>
  </li>
</ul>

<h2>Expressions and Patterns</h2>

<h3>Imperative constructions</h3>

<ul>
  <li>The sequence is introduced by the keyword "do" followed by "{"
    and terminated by "}"; it is possible to put a semicolon after the
    last expression:

    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>e1; e2; e3; e4</tt></td>
        <td><tt>do { e1; e2; e3; e4 }</tt></td>
      </tr>
    </table>
  </li>

  <li>The "do" after the "while" loop and the "for" loop are followed
    by a "{" and the loop end with "}"; it is possible to put a
    semicolon after the last expression:

    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>while e1 do</tt></td>
        <td><tt>while e1 do {</tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;e1; e2; e3</tt></td>
        <td><tt>&nbsp;&nbsp;e1; e2; e3</tt></td>
      </tr>
      <tr>
        <td><tt>done</tt></td>
        <td><tt>}</tt></td>
      </tr>
      <tr>
        <td><tt></tt></td>
        <td><tt></tt></td>
      </tr>
      <tr>
        <td><tt>for i = e1 to e2 do&nbsp;&nbsp;</tt></td>
        <td><tt>for i = e1 to e2 do {</tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;e1; e2; e3</tt></td>
        <td><tt>&nbsp;&nbsp;e1; e2; e3</tt></td>
      </tr>
      <tr>
        <td><tt>done</tt></td>
        <td><tt>}</tt></td>
      </tr>
    </table>
  </li>
</ul>

<h3>Tuples and Lists</h3>

<ul>
  <li>Parentheses are required in tuples:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>1, "hello", World</tt></td>
        <td><tt>(1, "hello", World)</tt></td>
      </tr>
    </table>
  </li>

  <li>Lists are always enclosed with brackets. A list is a left
    bracket, followed by a list of elements separated with semicolons,
    optionally followed by colon-colon and an element, and ended by a
    right bracket. Warning: the colon-colon is not an infix but is
    just part of the syntactic construction.
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>x :: y</tt></td>
        <td><tt>[x :: y]</tt></td>
      </tr>
      <tr>
        <td><tt>[x; y; z]</tt></td>
        <td><tt>[x; y; z]</tt></td>
      </tr>
      <tr>
        <td><tt>x :: y :: z :: t</tt></td>
        <td><tt>[x; y; z :: t]</tt></td>
      </tr>
    </table>
  </li>
</ul>

<h3>Records</h3>

<ul>
  <li>In record update, parentheses are required around the initial
    expression:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>{e with field = a}</tt></td>
        <td><tt>{(e) with field = a}</tt></td>
      </tr>
    </table>
  </li>

  <li>It is allowable to use function binding syntax in record field
    definitions:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>{field = fun a -> e}</tt></td>
        <td><tt>{field a = e}</tt></td>
      </tr>
    </table>
  </li>
</ul>

<h3>Irrefutable patterns</h3>

<p>An <em>irrefutable pattern</em> is a pattern which is
  syntactically visible and never fails. They are used in some
  syntactic constructions. It is either:</p>

<ul>
  <li>A variable,</li>
  <li>The wildcard "_",</li>
  <li>The constructor "()",</li>
  <li>A tuple with irrefutable patterns,</li>
  <li>A record with irrefutable patterns,</li>
  <li>A type constraint with an irrefutable pattern.</li>
</ul>

<p>Notice that this definition is only syntactic: a constructor
  belonging to a type having only one constructor is not considered as
  an irrefutable pattern (except "()").</p>

<h3>Constructions with matching</h3>

<ul>
  <li>The keyword "function" no longer exists. Only "fun" is used.</li>
  <li>The pattern matching, in constructions with "fun", "match" and
    "try" is closed with brackets: an open bracket "[" before the
    first case, and a close bracket "]" after the last case:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>match e with</tt></td>
        <td><tt>match e with</tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;p1 -> e1</tt></td>
        <td><tt>[ p1 -> e1</tt></td>
      </tr>
      <tr>
        <td><tt>| p2 -> e2</tt></td>
        <td><tt>| p2 -> e2 ]</tt></td>
      </tr>
    </table>
    If there is only one case and if the pattern is irrefutable,
      the brackets are not required. These examples work identically
      in OCaml and in revised syntax:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>fun x -> x</tt></td>
        <td><tt>fun x -> x</tt></td>
      </tr>
      <tr>
        <td><tt>fun {foo=(y, _)} -> y</tt></td>
        <td><tt>fun {foo=(y, _)} -> y</tt></td>
      </tr>
    </table>
  </li>
  <li>It is possible to write the empty function which always raises the
    exception "Match_failure" when a parameter is applied.  It is also possible to write and
    empty "match", raising "Match_failure" after having evaluated its
    expression and the empty "try", equivalent to its expression
    without try:
<pre>
  fun []
  match e with []
  try e with []
</pre>
  </li>
  <li>The patterns after "let" and "value" must be irrefutable. The
    following OCaml expression:
<pre>
  let f (x::y) = ...
</pre>
    must be written:
<pre>
  let f = fun [ [x::y] -> ...
</pre>
  </li>

  <li>It is possible to use a construction "where", equivalent to "let",
    but usable only when where is only one binding. The expression:
<pre>
  e1 where p = e
</pre>
    is equivalent to:
<pre>
  let p = e in e1
</pre>
  </li>
</ul>

<h3>Mutables and Assignment</h3>

<ul>
  <li>The statement "<tt>&lt;-</tt>" is written "<tt>:=</tt>":
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>x.f &lt;- y</tt></td>
        <td><tt>x.f := y</tt></td>
      </tr>
    </table>
  </li>

  <li>The "ref" type is declared as a record type with one field named
    "val", instead of "contents". The operator "!" does not exist any
    more, and references are assigned like the other mutables:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>x := !x + y</tt></td>
        <td><tt>x.val := x.val + y</tt></td>
      </tr>
    </table>
  </li>
</ul>

<h3>Miscellaneous</h3>

<ul>
  <li>The "<tt>else</tt>" is required in the "<tt>if</tt>"
    statement:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>if a then b</tt></td>
        <td><tt>if a then b else ()</tt></td>
      </tr>
    </table>
  </li>

  <li>The boolean operations "<tt>or</tt>" and "<tt>and</tt>" can only
    be written with "<tt>||</tt>" and "<tt>&amp;&amp;</tt>":
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>a or b &amp; c</tt></td>
        <td><tt>a || b &amp;&amp; c</tt></td>
      </tr>
      <tr>
        <td><tt>a || b &amp;&amp; c</tt></td>
        <td><tt>a || b &amp;&amp; c</tt></td>
      </tr>
    </table>
  </li>

  <li>No more "<tt>begin end</tt>" construction. One must use
    parentheses.</li>

  <li>The operators as values are written with an backslash:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>(+)</tt></td>
        <td><tt>\+</tt></td>
      </tr>
      <tr>
        <td><tt>(mod)</tt></td>
        <td><tt>\mod</tt></td>
      </tr>
    </table>
  </li>

  <li>Nested "as" patterns require parenthesis:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>function Some a as b, c -></tt></td>
        <td><tt>fun [ ((Some a as b), c) -></tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;...</tt></td>
        <td><tt>&nbsp;&nbsp;...</tt></td>
      </tr>
    </table>
    But they are not required before the right arrow:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>function Some a as b -></tt></td>
        <td><tt>fun [ Some a as b -></tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;...</tt></td>
        <td><tt>&nbsp;&nbsp;...</tt></td>
      </tr>
    </table>
  </li>

  <li>The operators with special characters are not automatically
    infix. To define infixes, use syntax extensions.
  </li>
</ul>

<h2>Types and Constructors</h2>

<ul>
  <li>The type constructors are before their type parameters, which
    are curryfied:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>int list</tt></td>
        <td><tt>list int</tt></td>
      </tr>
      <tr>
        <td><tt>('a, bool) Hashtbl.t</tt></td>
        <td><tt>Hashtbl.t 'a bool</tt></td>
      </tr>
      <tr>
        <td><tt>type 'a foo = 'a list list</tt></td>
        <td><tt>type foo 'a = list (list 'a)</tt></td>
      </tr>
    </table>
  </li>

  <li>The abstract types are represented by an unbound type variable:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>type 'a foo;;</tt></td>
        <td><tt>type foo 'a = 'b;</tt></td>
      </tr>
      <tr>
        <td><tt>type bar;;</tt></td>
        <td><tt>type bar = 'a;</tt></td>
      </tr>
    </table>
  </li>

  <li>Parentheses are required in tuples of types:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>int * bool</tt></td>
        <td><tt>(int * bool)</tt></td>
      </tr>
    </table>
  </li>

  <li>In declarations of a concrete type, brackets must enclose the
    constructor declarations:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>type t = A of i | B;;</tt></td>
        <td><tt>type t = [ A of i | B ];</tt></td>
      </tr>
    </table>
  </li>

  <li>It is possible to make the empty type, without constructor:
<pre>
  type foo = [];
</pre>
  </li>

  <li>There is a syntax difference between data constructors with
    several parameters and data constructors with one parameter of type
    tuple:<br/><br/>

    The declaration of a data constructor with several parameters
    is done by separating the types with "and". In expressions and
    patterns, these constructor parameters must be curryfied:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>type t = C of t1 * t2;;</tt></td>
        <td><tt>type t = [ C of t1 and t2 ];</tt></td>
      </tr>
      <tr>
        <td><tt>C (x, y);;</tt></td>
        <td><tt>C x y;</tt></td>
      </tr>
    </table>

    The declaration of a data constructor with one parameter of type
    tuple is done by using a tuple type. In expressions and patterns,
    the parameter must not to be curryfied, since it is alone. In that
    case the syntax of constructor parameters is the same between the
    two syntaxes:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>type t = D of (t1 * t2);;</tt></td>
        <td><tt>type t = [ D of (t1 * t2) ];</tt></td>
      </tr>
      <tr>
        <td><tt>D (x, y);;</tt></td>
        <td><tt>D (x, y);</tt></td>
      </tr>
    </table>
  </li>

  <li>The bool constructors start with an uppercase letter. The identifiers
    "true" and "false" are not keywords:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>true &amp;&amp; false</tt></td>
        <td><tt>True &amp;&amp; False</tt></td>
      </tr>
    </table>
  </li>

  <li>In record types, the keyword "mutable" must appear after the
    colon:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>type t = {mutable x : t1};;</tt></td>
        <td><tt>type t = {x : mutable t1};</tt></td>
      </tr>
    </table>
  </li>

  <li>Manifest types are with "==":
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>type 'a t = 'a option =</tt></td>
        <td><tt>type t 'a = option 'a ==</tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;&nbsp;&nbsp;None</tt></td>
        <td><tt>&nbsp;&nbsp;[ None</tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;| Some of 'a</tt></td>
        <td><tt>&nbsp;&nbsp;| Some of 'a ]</tt></td>
      </tr>
    </table>
  </li>

  <li>Polymorphic types start with "<tt>!</tt>":
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>type t =</tt></td>
        <td><tt>type t =</tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;{ f : 'a . 'a list }</tt></td>
        <td><tt>&nbsp;&nbsp;{ f : ! 'a . list 'a }</tt></td>
      </tr>
    </table>
  </li>
</ul>

<h2>Streams and Parsers</h2>

<ul>
  <li>The streams and the stream patterns are bracketed with "<tt>[:</tt>"
    and "<tt>:]</tt>" instead of "<tt>[&lt;</tt>" and "<tt>&gt;]</tt>".
  </li>
  <li>The stream component "terminal" is written with a back-quote
    instead of a quote:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>[&lt; '1; '2; s; '3 &gt;]</tt></td>
        <td><tt>[: `1; `2; s; `3 :]</tt></td>
      </tr>
    </table>
   </li>
   <li>The cases of parsers are bracketed with "<tt>[</tt>" and
     "<tt>]</tt>", as with "fun", "match" and "try". If there is one
     case, the brackets are not required:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>parser</tt></td>
        <td><tt>parser</tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;[&lt; 'Foo &gt;] -> e</tt></td>
        <td><tt>[ [: `Foo :] -> e</tt></td>
      </tr>
      <tr>
        <td><tt>| [&lt; p = f &gt;] -> f;;</tt></td>
        <td><tt>| [: p = f :] -> f ];</tt></td>
      </tr>
      <tr>
        <td><tt>parser [&lt; 'x &gt;] -> x;;</tt></td>
        <td><tt>parser [: `x :] -> x;</tt></td>
      </tr>
    </table>
  </li>
   <li>It is possible to write the empty parser raising the exception
     "Stream.Failure" whatever parameter is applied, and the empty
     stream matching always raising "Stream.Failure":
<pre>
  parser []
  match e with parser []
</pre>
   </li>
   <li>In normal syntax, the error indicator starts with a double question
     mark, in revised syntax with a simple question mark:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>parser</tt></td>
        <td><tt>parser</tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;[&lt; '1; '2 ?? "error" &gt;] -></tt></td>
        <td><tt>&nbsp;&nbsp;[: `1; `2 ? "error" :] -></tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;&nbsp;&nbsp;...</tt></td>
        <td><tt>&nbsp;&nbsp;&nbsp;&nbsp;...</tt></td>
      </tr>
    </table>
  </li>
  <li>In normal syntax, the component optimization starts with
     "<tt>?!</tt>", in revised syntax with "<tt>!</tt>":
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>parser</tt></td>
        <td><tt>parser</tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;[&lt; '1; '2 ?! &gt;] -></tt></td>
        <td><tt>&nbsp;&nbsp;[: `1; `2 ! :] -></tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;&nbsp;&nbsp;...</tt></td>
        <td><tt>&nbsp;&nbsp;&nbsp;&nbsp;...</tt></td>
      </tr>
    </table>
  </li>
</ul>

<h2>Classes and Objects</h2>

<ul>
  <li>Object items end with a single semicolon which is required.</li>
  <li>Class type parameters follow the class identifier:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>class ['a, 'b] point = ...</tt></td>
        <td><tt>class point ['a, 'b] = ...</tt></td>
      </tr>
      <tr>
        <td><tt>class c = [int] color;;</tt></td>
        <td><tt>class c = color [int];</tt></td>
      </tr>
    </table>
  </li>
  <li>In the type of class with parameters, the type of the parameters
    are between brackets. Example in signature:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>class c : int -> point;;</tt></td>
        <td><tt>class c : [int] -> point;</tt></td>
      </tr>
    </table>
  </li>
  <li>The keywords "virtual" and "private" must be in this order:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>method virtual private m :</tt></td>
        <td><tt>method virtual private m :</tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;...</tt></td>
        <td><tt>&nbsp;&nbsp;...</tt></td>
      </tr>
      <tr>
        <td><tt>method private virtual m :</tt></td>
        <td><tt>method virtual private m :</tt></td>
      </tr>
      <tr>
        <td><tt>&nbsp;&nbsp;...</tt></td>
        <td><tt>&nbsp;&nbsp;...</tt></td>
      </tr>
    </table>
  </li>
  <li>Object variables are introduced with "value" instead of "val":
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>object val x = 3 end</tt></td>
        <td><tt>object value x = 3; end</tt></td>
      </tr>
    </table>
  </li>
  <li>Type constraints in objects are introduced with "type" instead of
    "constraint":
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>object constraint 'a = int end</tt></td>
        <td><tt>object type 'a = int; end</tt></td>
      </tr>
    </table>
  </li>
</ul>

<h2>Labels and Variants</h2>

<ul>
  <li>Labels in types must start with "<tt>~</tt>":
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>val x : num:int -> bool;;</tt></td>
        <td><tt>value x : ~num:int -> bool;</tt></td>
      </tr>
    </table>
  </li>

  <li>Types whose number of variants are fixed start with "<tt>[ =</tt>":
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>type t = [`On | `Off];;</tt></td>
        <td><tt>type t = [ = `On | `Off];</tt></td>
      </tr>
    </table>
  </li>

  <li>The "<tt>[</tt>" and the "<tt>&lt;</tt>" in variant types must
    not be sticked:
    <table width="75%" class="centered" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left" class="half">OCaml</th>
        <th align="left" class="half">Revised</th>
      </tr>
      <tr>
        <td><tt>type t = [&lt; `Foo | `Bar ];;</tt></td>
        <td><tt>type t = [ &lt; `Foo | `Bar ];</tt></td>
      </tr>
    </table>
  </li>
</ul>

<div class="trailer">
</div>

</div>

</body>
</html>