Caml

Caml（Categorical Abstract Machine Language：範疇抽象機語言），是一種函數式、指令式的程式語言。最早由法國的INRIA和ENS聯合的Formel項目發展出來，是ML語言的兩種方言之一，現在主要由INRIA負責維護與發展。Caml是一種語言規範；它早期有過幾個實現，目前除了仍然活躍的OCaml，發佈於2002年的Caml Light是Caml的另一個實現。

**歷史**
在1981年，INRIA的Gérard Huet，將最初的LCF ML適配到Multics系統的Maclisp下，並且增加了編譯器。這個實現被描述於INRIA內部文檔“ML手冊”之中archive-url=https://web.archive.org/web/20220129103018/http://www.nuprl.org/crash/eventml/KreitzandRahli-ClassicML.pdf，它被開發者自稱為“Le_ML”Our main reason for developing Caml was to use it for sofware development inside Formel. Indeed, it was used for developing the Coq system ……. We were reluctant to adopt a standard that could later prevent us from adapting the language to our programming needs. ……We did incorporate into Caml most of the improvements brought by Standard ML over Edinburgh ML. ……The first implementation of Caml appeared in 1987 and was further developed until 1992. It was created mainly by Ascander Suarez. ……In 1990 and 1991, Xavier Leroy designed a completely new implementation of Caml, based on a bytecode interpreter written in C. Damien Doligez provided an excellent memory management system. ……In 1995, Xavier Leroy released Caml Special Light, which improved over Caml Light in several ways. First, an optimizing native-code compiler was added to the bytecode compiler. ……Second, Caml Special Light offered a high-level module system, designed by Xavier Leroy and inspired by the module system of Standard ML. ……Didier Rémy, later joined by Jérôme Vouillon, designed an elegant and highly expressive type system for objects and classes. This design was integrated and implemented within Caml Special Light, leading to the Objective Caml language and implementation, first released in 1996 and renamed to OCaml in 2011.|access-date=2021-09-06|archive-date=2022-04-13|archive-url=https://web.archive.org/web/20220413084146/https://caml.inria.fr/about/history.en.html。劍橋大學的Lawrence Paulson用它開發了Cambridge LCF，而劍橋大學的Michael J. C. Gordon用它開發了第一版的HOL。這個ML系統由INRIA和劍橋大學聯合維護和發行。
基於Thierry Coquand在1985年的關於構造演算的論文，INRIA的Formel項目開始致力於參與Coq的開發。在1987年，INRIA的Ascánder Suárez，基於巴黎第七大學的Guy Cousineau的“Categorical abstract machine”（CAM）archive-url=https://web.archive.org/web/20220128115221/http://michel.mauny.net/data/papers/mauny-suarez-1986.pdf LFP '86: Proceedings of the 1986 ACM conference on LISP and functional programming, Pages 266–278.，利用Le Lisp的運行時間系統重新實現了Le_ML，並正式命名為“Caml”archive-url=https://web.archive.org/web/20220406231614/https://hal.inria.fr/inria-00070046/document Research Report RT-0121, INRIA. pp.491.。
在1990年和1991年，INRIA的Xavier Leroy基於用C實現的字節碼解釋器，利用Damien Doligez提供的內存管理系統重新實現了Caml，並稱其為“Caml Light”。在1995年，Xavier Leroy又增加了本機代碼編譯器和高層模塊系統，這個版本也稱為“Caml Special Light”。在1996年，INRIA的Didier Rémy和Jérôme Vouillon，向Caml Special Light增加了面向對象特徵archive-url=https://web.archive.org/web/20220121031810/http://gallium.inria.fr/~remy/ftp/objective-ml!popl97.pdfarchive-url=https://web.archive.org/web/20220120081109/https://caml.inria.fr/pub/papers/remy_vouillon-objective_ml-tapos98.pdf，從而創建了OCaml。

**範例**

**Hello World**
下面的程序hello.ml:
print_endline "Hello World!"

**階乘函數**
很多數學函數，比如階乘，可以很自然的表示為純粹的函數形式：
let rec fact n =
if n=0 then 1 else n * fact(n - 1);;
這個函數可以使用模式匹配等價的寫為：
let rec fact = function

0 -> 1

n -> n * fact(n - 1);;
後者形式是階乘作為遞推關係的數學定義。
編譯器將這個函數的類型推論為int -> int，意味著這個函數將int映射到int。例如，12!：
# fact 12;;
- : int = 479001600

**引用==