Version française
Home     About     Download     Resources     Contact us    
Browse thread
RE: [Caml-list] recursive modules redux, & interface files
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] recursive modules redux, & interface files
Dave Berry wrote:
> 
> Pardon me if this is a dumb question, but what is the difference between
> "include" and "open"?

	Open simply changes the way lookup is done: the 'environment;
in which definitions in a module are defined. It doesn't change the
interface of the module, or define anything in the module.

	Include adds the definitions of one module as definitions
of another module, more or less saving a lot of typing.

	(* o.ml *)
	open List
	let f = map
	(* this module contains one symbol, 'f' *)

	(* i.ml *)
	include List
	let f = map
	(* this module contains 'map', as well as 'f',
 	indeed, everything in 'List' *)

	(* client.ml *)
	let _ = O.f .... (* OK *)
	let _ = O.map .. (* error *)
	let _ = I.f ... (* OK *)
	let _ = I.map .. (* OK, synonym for List.map *)

In other words, O is a client of List, whereas I is an extension
of List.

BTW: include was already available for signatures, but not open.
Is this right? Can 'open' be made available for signatures?
[This would shorten .mli files a lot, make them more readable]

-- 
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr