[
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: | 2001-04-29 (22:24) |
From: | Brian Rogoff <bpr@b...> |
Subject: | Re: [Caml-list] two unrelated questions |
On Fri, 27 Apr 2001, Anton Moscal wrote: > For this problem workaround exists: > > let f x = > let module M = struct > exception Break > let v = try ... raise Break ... with Break ->... > end > in M.v I think the real beauty of this local module feature is that it allows things like a local open, which may make open more palatable to open-phobes. For instance if you want to get a date but don't want to "pollute" the namespace with an open'ed Unix module you can write let get_date () = let module M = struct open Unix let current_time = localtime (time()) let current_date = { year = current_time.tm_year ; month = current_time.tm_mon + 1 ; day = current_time.tm_mday ; hour = current_time.tm_hour ; minute = current_time.tm_min ; second = current_time.tm_sec } end in M.current_date though I take it that these kinds of tricks weren't the original goal of the feature. Still, the syntax is light so these are very painless workarounds even without the P4 prettification. -- Brian ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr