Version française
Home     About     Download     Resources     Contact us    
Browse thread
Local "open", or open locally
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Lukasz Stafiniak <lukstafi@g...>
Subject: Local "open", or open locally
Dear list,

What about a construct for opening modules locally in an expression? For example

module SomeModule = struct let x = 5 end
module SomeOtherModule = struct let y = 7 end

let z = open SomeModule and SomeOtherModule in x + y + x*y

It can currently be expressed as:

let z = module XY = struct open SomeModule open SomeOtherModule
  let z = x + y + x*y end in XY.z

Perhaps it could be considered as a language extension. It seems nice
as it "catches the focus". (I'm going to use it with Camlp4 but it
seems uglier that way.)

I wouldn't buy it for my kidney, though. ;)

Best Regards,
Lukasz Stafiniak