Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Wanted: your feedback on the hierarchy of OCaml Batteries Included
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-11-20 (11:32)
From: Daniel_Bünzli <daniel.buenzli@e...>
Subject: Re: [Caml-list] open Module (not?) considered harmful

Le 20 nov. 08 à 11:49, Stefano Zacchiroli a écrit :

> Problem 1) once you open you loose the information where an identifier
>  comes from. True, but it is a tool deficiency, not an intrinsic
>  deficiency.

I disagree. Having to invoke a tool to know where an identifier comes  
from when I read code involves one more (superfluous IMHO) action. Not  
to mention that I do sometimes print code on real paper to read it.

I want to be able to read code without the need of invoking tools  
every two lines, thus I try to follow this policy :

- Any non prefixed identifier in a file is defined in that file.

This makes reading and navigating through the code much more easier.  
The less there are implicit definitions in my code, the better.

I do not object using open for external libraries that pack some  
related _modules_ in a _single level_ hierarchy but I clearly see no  
benefit of having to open things to use the standard library  
(especially to use something as ubiquituous as lists).

> Problem 2) "open Module" is too broad, hence it "splice in" the
>  current scope all identifiers of Module.

This problem doesn't occur if you pack only closely related _modules_   
in the module you open.