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
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: 2001-03-28 (07:47)
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.

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

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

	(* *)
	let _ = O.f .... (* OK *)
	let _ = .. (* error *)
	let _ = I.f ... (* OK *)
	let _ = .. (* OK, synonym for *)

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,
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper
download Interscript
To unsubscribe, mail  Archives: