Re: [Caml-list] Extending modules and signatures

2009-04-21 Thread Ashish Agarwal
> I think the real issue is inheritance. Yes. Your example adds an extra complication by using references. Forgoing that, I get around this within the current module system by defining a base module B, which two other modules C an D "inherit", i.e. they just include B. Module B has the common value

Re: [Caml-list] Extending modules and signatures

2009-04-20 Thread Martin Jambon
Goswin von Brederlow wrote: > Which would also need > > module A1 = new module A > module A2 = new module A > A1.incr_x () > A1.get_x;; > - : int = 124 > A2.get_x ();; > - : int = 123 > > So you see A does not have global variables but only instance > variables. What you describe are ocaml object

Re: [Caml-list] Extending modules and signatures

2009-04-19 Thread Goswin von Brederlow
Martin Jambon writes: > OK, but I think the real issue is inheritance. In order to truly extend an > existing module, one needs to access the private items of the inherited module > implementation. In order to avoid messing up with the original module's > global variables, the inherited "module

Re: [Caml-list] Extending modules and signatures

2009-04-19 Thread Goswin von Brederlow
Jon Harrop writes: > On Sunday 19 April 2009 22:36:12 Ashish Agarwal wrote: >> Having the compiler introduce module type names automatically from mli >> files would be very helpful, and I don't see any disadvantages. > > Some people contest the idea that files should automatically convey module

Re: [Caml-list] Extending modules and signatures

2009-04-19 Thread Martin Jambon
Ashish Agarwal wrote: >> The module type exists, it's just that it doesn't have a name. > > Right, thanks for the clarification. > > >> let x = (123, "abc") >> does not define "type x = int * string" either. > > True, but I think the expectations are different for module types. A > file a.ml

Re: [Caml-list] Extending modules and signatures

2009-04-19 Thread Jon Harrop
On Sunday 19 April 2009 22:36:12 Ashish Agarwal wrote: > > The module type exists, it's just that it doesn't have a name. > > Right, thanks for the clarification. > > > let x = (123, "abc") > > does not define "type x = int * string" either. > > True, but I think the expectations are different for

Re: [Caml-list] Extending modules and signatures

2009-04-19 Thread Ashish Agarwal
> The module type exists, it's just that it doesn't have a name. Right, thanks for the clarification. > let x = (123, "abc") > does not define "type x = int * string" either. True, but I think the expectations are different for module types. A file a.ml creates a module named A, and it seems nat

Re: [Caml-list] Extending modules and signatures

2009-04-18 Thread Martin Jambon
Ashish Agarwal wrote: > This is a commonly requested feature. Ah. > One issue is that a file a.ml > creates a module A. However, a file a.mli does not create > a module type A. I'm not sure why this is the case. Does anyone know if > there is a specific reason? The module type exis

Re: [Caml-list] Extending modules and signatures

2009-04-17 Thread Ashish Agarwal
This is a commonly requested feature. One issue is that a file a.ml creates a module A. However, a file a.mli does not create a module type A. I'm not sure why this is the case. Does anyone know if there is a specific reason? On Fri, Apr 17, 2009 at 4:51 PM, Peter Hawkins wrote: > Hi... > > I hav

Re: [Caml-list] Extending modules and signatures

2009-04-17 Thread Goswin von Brederlow
Peter Hawkins writes: > Hi... > > I have a quick question. I want to extend the List module with various > functions that I want that aren't present in the standard library, > much as the Batteries ExtList library does. > > I might write the following code in "mylibrary.ml": > module MyList = str

Re: [Caml-list] Extending modules and signatures

2009-04-17 Thread Dario Teixeira
Hi, > I have a quick question. I want to extend the List module with various > functions that I want that aren't present in the standard library, > much as the Batteries ExtList library does. I reckon you want something like this: http://caml.inria.fr/mantis/view.php?id=3013 Cheers, Dario Tei

[Caml-list] Extending modules and signatures

2009-04-17 Thread Peter Hawkins
Hi... I have a quick question. I want to extend the List module with various functions that I want that aren't present in the standard library, much as the Batteries ExtList library does. I might write the following code in "mylibrary.ml": module MyList = struct include List let foo x = ... c