From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA15529 for caml-redist; Wed, 26 Apr 2000 15:37:05 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA15897 for ; Wed, 26 Apr 2000 08:57:41 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id IAA05524 for ; Wed, 26 Apr 2000 08:57:39 +0200 (MET DST) Received: from localhost (sansho.kurims.kyoto-u.ac.jp [130.54.16.90]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id PAA03824 for ; Wed, 26 Apr 2000 15:57:37 +0900 (JST) To: caml-list@inria.fr Subject: Upgrading from OCaml 2.99 or OLabl to OCaml 3.00 X-Mailer: Mew version 1.93 on Emacs 20.5 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20000426155736O.garrigue@kurims.kyoto-u.ac.jp> Date: Wed, 26 Apr 2000 15:57:36 +0900 From: Jacques Garrigue X-Dispatcher: imput version 980905(IM100) Sender: weis Objective Caml 3.00 has been released, and it is finally quite different from 2.99. Here is a summary of the changes, to help you upgrade. (This is not in the OCaml Changelog, since 2.99 was only a beta) There are also tools to help you, presented at the end of this note. * Syntax - Labels: to keep maximal compatibility with OCaml 2.0x, the syntax of labels in programs changed. Here is a conversion table (1): label: -> ~label: :label -> ~label (label:x : type)-> ~label:(x : type) (:label : type) -> ~(label : type) ?label: -> ?label: (unchanged) ?:label -> ?label ?(label:x = v) -> ?label:(x = v) ?(:label = v) -> ?(label = v) Notice that you cannot use keywords as labels anymore. Also, for OLabl programs, the syntax for default values changed: ?label:x [< v >] -> ?label:(x = v) Semantics of optional parameters were changed between OLabl and OCaml 2.99. See the tutorial for the new semantics. - Syntax of labels in types do not change (no extra ~). - Variant types: in order to get more symmetry with sum types, an extra "of" was introduced before the parameter type. [`A int | `B bool] -> [`A of int | `B of bool] * Labelling of libraries The labellings of many functions in the libraries were changed, for various reasons. - To reduce the number of labelled functions in the standard libraries. Basically, labels were omitted wherever they do not provide useful information. E.g. List.nth : 'a list -> pos:int -> 'a became List.nth : 'a list -> int -> 'a In practice, most functions of two arguments were removed their labels. - To avoid keyword labels, like fun:, to:, in:, end: ... There is no exhaustive list of label changes, but here are some of them: fun: -> f: pred: -> f: end: -> stop: to: -> (no label) key:,pos:,len:,size: -> often omitted - Also there were changes in LablTk, to uniformize, and make easier use in classic mode. The standard parameter order is now * when there are optional arguments * when there are no optional arguments In the Canvas module, both the widget and the shape id are left unlabelled. Helpful tools * ocaml299to3 This simple program does label syntax conversion automatically, following table (1). Also, it systematically converts fun: into f:. (Other label changes have to be done by hand.) It is clever enough to distinguish between terms and types (where no conversion should be done). Since it only inserts "~"'s in your code, layout and comments are preserved. To convert all files in a directory, just type: % ocaml299to3 *.ml For all modified files, the orignal is kept as file.bak. * Camlp4 3.00 If you prefer the old syntax, using only ":", camlp4 can help you. In the upcoming release of camlp4, a grammar pa_olabl is provided that parses Ocaml 2.99 syntax. This does not mean that your programs will run unmodified, since many labels changed in 3.00, but you can keep the old style. Quoting Daniel de Raglaudre, here is how to use it: To compile with the 2.99 syntax, use ocamlc -pp "camlp4o pa_olabl.cmo" To switch the toplevel syntax to 2.99, ocaml -I `camlp4 -where` # #load "camlp4o.cma";; (* Camlp4 parses *) # #load "pa_olabl.cmo";; (* switch parser to 2.99 *) To create a toplevel parsing the 2.99 syntax, ocamlmktop -o olabl -I `camlp4 -where` gramlib.cma \ camlp4_top.cma pa_olabl.cmo This information, and eventual updates, wil be available at http://wwwfun.kurims.kyoto-u.ac.jp/soft/olabl/compat.html --------------------------------------------------------------------------- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp JG