20.03.2015 Views

The Objective Caml system release 3.06 - The Caml language - Inria

The Objective Caml system release 3.06 - The Caml language - Inria

The Objective Caml system release 3.06 - The Caml language - Inria

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Contents<br />

I An introduction to <strong>Objective</strong> <strong>Caml</strong> 9<br />

1 <strong>The</strong> core <strong>language</strong> 11<br />

1.1 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11<br />

1.2 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12<br />

1.3 Functions as values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13<br />

1.4 Records and variants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14<br />

1.5 Imperative features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16<br />

1.6 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18<br />

1.7 Symbolic processing of expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 19<br />

1.8 Pretty-printing and parsing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20<br />

1.9 Standalone <strong>Caml</strong> programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23<br />

2 <strong>The</strong> module <strong>system</strong> 25<br />

2.1 Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25<br />

2.2 Signatures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26<br />

2.3 Functors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27<br />

2.4 Functors and type abstraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29<br />

2.5 Modules and separate compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31<br />

3 Objects in <strong>Caml</strong> 33<br />

3.1 Classes and objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33<br />

3.2 Reference to self . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36<br />

3.3 Initializers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36<br />

3.4 Virtual methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37<br />

3.5 Private methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38<br />

3.6 Class interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40<br />

3.7 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41<br />

3.8 Multiple inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42<br />

3.9 Parameterized classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42<br />

3.10 Polymorphic methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45<br />

3.11 Using coercions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48<br />

3.12 Functional objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52<br />

3.13 Cloning objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53<br />

3.14 Recursive classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56<br />

3.15 Binary methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56<br />

1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!