The revised syntax

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.

Notice that there is a simple way to know how the normal syntax is written in revised syntax: write the code in a file "" in normal syntax and type, in a shell:

  camlp5o pr_r.cmo pr_rp.cmo

And, conversely, how a file "" written in revised syntax is displayed in normal syntax:

  camlp5r pr_o.cmo pr_op.cmo

Even simpler, without creating a file:

  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 ...
  1. Lexing
  2. Modules, Structure and Signature items
  3. Expressions and Patterns
  4. Types and Constructors
  5. Streams and Parsers
  6. Classes and Objects
  7. Labels and Variants


Modules, Structure and Signature items

Expressions and Patterns

Imperative constructions

Tuples and Lists


Irrefutable patterns

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

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 "()").

Constructions with matching

Mutables and Assignment


Types and Constructors

Streams and Parsers

Classes and Objects

Labels and Variants

Copyright 2007-2012 Daniel de Rauglaudre (INRIA)

Valid XHTML 1.1