4.02.0
版本发布时间: 2018-06-12 18:35:52
ocaml/ocaml最新发布版本:5.2.0(2024-05-13 20:27:08)
Some of the highlights in release 4.02 are:
-
In a first step towards making strings immutable, a type bytes of mutable byte arrays and a supporting library module
Bytes
were introduced. By default,bytes
is a synonym forstring
, so existing code that mutates values of typestring
still compiles, with warnings. Option-safe-string
separates the typesstring
andbytes
, making strings immutable. -
The
match
construct was extended to discriminate not just on the value of its argument expression, but also on exceptions arising out of the evaluation of this expression. This solves an old problem: in alet x = a in b
, catch exceptions raised bya
but not those raised byb
. -
Module aliases (giving an alternative name to an existing module or compilation unit, as in
module M = AnotherModule
) are now tracked specially by the type system and the compiler. This enables not only more precise typing of applicative functors, but also more precise dependency analysis at link-time, potentially reducing the size of executables. -
Annotations can now be attached to most syntactic elements of OCaml sources (expressions, definitions, type declarations, etc). These annotations are used by the compiler (e.g. to warn on uses of functions annotated as deprecated) but also by "ppx" preprocessors, to guide rewriting of abstract syntax trees.
-
Extensible data types can be declared (
type t = ..
) then later extended with new constructors (type t += A of int
). This generalizes the handling of the exn type of exception values. -
Functors and functor applications can now take a special () argument to force generativity of abstract types.
-
New toplevel directives
#show_type
,#show_modules
, etc, to query the toplevel environment. -
Performance of
ocamlopt
-generated code is improved on some programs through more aggressive constant propagation, two new optimization passes (dead code elimination and common subexpression elimination), better compilation of pattern-matching over strings, optimized representation of constant exceptions, and GC tuning for large memory heaps. -
The format strings argument of
printf
functions are now represented as a GADT. This speeds up theprintf
functions considerably, and leads to more precise typechecking of format strings. -
The native-code compiler now supports the AArch64 (ARM 64 bits) architecture.
-
The Camlp4 preprocessor and the Labltk library were split off the distribution. They are now separate projects.
See also: detailed list of changes.