[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Anton Moscal <msk@p...> |
| Subject: | Local definitions |
Hello!
Why CaML doesn't not allow the following style of local definitions:
declare
<definition> ...
in
<expression>
with following translation:
let module Temp = struct
<definition>...
let result = <expression>
end in
Temp.result
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
try
Array.iteri (fun i elem -> if elem = x then raise (Return i)) vec;
None
with
Return i -> Some i
can be translated as:
let find x vec =
let module T = struct
exception Return of int
let res =
try
Array.iteri (fun i elem -> if elem = x then raise (Return i)) vec;
None
with
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