caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* functors in batch compilation
@ 1997-05-05 23:51 Lyn A Headley
  1997-05-07  9:18 ` Francois Rouaix
  0 siblings, 1 reply; 2+ messages in thread
From: Lyn A Headley @ 1997-05-05 23:51 UTC (permalink / raw)
  To: caml-list

hello,

While I think the Ocaml manual gives a good general tutorial on the
subject of the Module system, I am still confused about the _details_
of functorizing a module in a file.  

The docs provide this hint:

Notice that only top-level structures can be mapped to
separately-compiled files, but not functors nor module types. However,
all module-class objects can appear as components of a structure, so
the solution is to put the functor or module type inside a structure,
which can then be mapped to a file.


but does this mean one is forced to declare a functorized struct
in a signature as well as in the implementation file?  It would
seem to make more sense for the compiler to realize that it was
dealing with an implementation of a single module described in the
implementation file and just allow the signature to describe the
values of the (functorized) module that it wants to export.  This
would avoid needing two names per module, one for the file and another
for the module.  

I realize I might not be making sense but basically I don't understand
how to compile a functorized module into a file, and I wanted to prove
that I at least thought about it, thereby lessening the impression
that I am a punk kid who don't know nothin.

Lyn





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: functors in batch compilation
  1997-05-05 23:51 functors in batch compilation Lyn A Headley
@ 1997-05-07  9:18 ` Francois Rouaix
  0 siblings, 0 replies; 2+ messages in thread
From: Francois Rouaix @ 1997-05-07  9:18 UTC (permalink / raw)
  To: Lyn A Headley; +Cc: caml-list

> but does this mean one is forced to declare a functorized struct
> in a signature as well as in the implementation file?

You are never forced to write .mli files, but it's good practice, both
for documentation purposes and for better separate compilation performance.

>  It would
> seem to make more sense for the compiler to realize that it was
> dealing with an implementation of a single module described in the
> implementation file and just allow the signature to describe the
> values of the (functorized) module that it wants to export.  This
> would avoid needing two names per module, one for the file and another
> for the module.  
When defining functors, there are usually two components in the implementation
file. One is the "module type" for the functor argument, the other is
the functor itself.

> I realize I might not be making sense but basically I don't understand
> how to compile a functorized module into a file, and I wanted to prove
> that I at least thought about it, thereby lessening the impression
> that I am a punk kid who don't know nothin.
Have you checked the library ? Several modules contain functors (e.g. Set
or Map).

--f






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-05-07  9:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-05-05 23:51 functors in batch compilation Lyn A Headley
1997-05-07  9:18 ` Francois Rouaix

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).