Local definitions

From: Anton Moscal (msk@post.tepkom.ru)
Date: Mon Oct 05 1998 - 16:27:18 MET DST

Date: Mon, 5 Oct 1998 18:27:18 +0400 (MSD)
From: Anton Moscal <msk@post.tepkom.ru>
To: caml-list@inria.fr
Subject: Local definitions
In-Reply-To: <199809280951.LAA27562@pauillac.inria.fr>


Why CaML doesn't not allow the following style of local definitions:

   <definition> ...

with following translation:

let module Temp = struct
  let result = <expression>
end in

or, the second variant: simply allow declaration of
types, exceptions, open statements and others in "let-in"
expressions with the same translation:

let find x vec =
  let exception Return of int in
    Array.iteri (fun i elem -> if elem = x then raise (Return i)) vec;
    Return i -> Some i
can be translated as:

let find x vec =
  let module T = struct
    exception Return of int
    let res =
        Array.iteri (fun i elem -> if elem = x then raise (Return i)) vec;
        Return i -> Some i
  end in T.res

This syntax allow more convenient notation for local types,
classes, exceptions and others definitions, than explicit usage of
local modules.

Anton E. Moscal msk@vvv.niimm.spb.ru

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:16 MET