* Checking an interface against an implementation
@ 2005-12-05 10:24 Daniel Bünzli
2005-12-05 11:46 ` [Caml-list] " Richard Jones
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Bünzli @ 2005-12-05 10:24 UTC (permalink / raw)
To: caml-list
Hello,
Is there a compiler invocation that allows to check that a particular
cmo or cmx implements a given cmi ?
I have some compilation units which are completely transparent to
each other (i.e no .mli). However for the final client of these units
I provide constrained interfaces specified in another directory. For
example,
mylib/a.ml
mylib/b.ml
mylib/api/a.mli
mylib/api/b.mli
Whenever I compile an .mli to a .cmi I would like to check that its
corresponding .cmo implements it. The problem is that syntactically
correct cmi always compile whithout problems. So if my .cmo doesn't
implement my .cmi I only get an (uninformative) error when I try to
actually link these units with the client.
Thanks for your answers,
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Checking an interface against an implementation
2005-12-05 10:24 Checking an interface against an implementation Daniel Bünzli
@ 2005-12-05 11:46 ` Richard Jones
2005-12-05 14:00 ` Daniel Bünzli
0 siblings, 1 reply; 3+ messages in thread
From: Richard Jones @ 2005-12-05 11:46 UTC (permalink / raw)
To: Daniel Bünzli; +Cc: caml-list
On Mon, Dec 05, 2005 at 11:24:29AM +0100, Daniel Bünzli wrote:
> Is there a compiler invocation that allows to check that a particular
> cmo or cmx implements a given cmi ?
I think the tool you're looking for is "objinfo" -- on Linux it's
usually installed as "ocamlobjinfo". However this tool only works on
.cmi's or .cmo's, not .cmx's.
Rich.
--
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Checking an interface against an implementation
2005-12-05 11:46 ` [Caml-list] " Richard Jones
@ 2005-12-05 14:00 ` Daniel Bünzli
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Bünzli @ 2005-12-05 14:00 UTC (permalink / raw)
To: caml-list
Le 5 déc. 05 à 12:46, Richard Jones a écrit :
> I think the tool you're looking for is "objinfo" -- on Linux it's
> usually installed as "ocamlobjinfo". However this tool only works on
> .cmi's or .cmo's, not .cmx's.
Thanks for the info (however note that this tool doesn't seem to be
installed by default, at least if you compile from the source).
However I think what I want to do is impossible, apparently cmo
record the cmi they were compiled with (in my case the one
automatically generated) and refuse to link if the client was
compiled with a different cmi. In other words a .cmo can have only
one .cmi, is that true ?
One way to achieve what I want is to do the following
mylib/a.ml
mylib/b.ml
mylib/mylib.ml
mylib/mylib.mli
Such that mylib.ml is :
module A = A
module B = B
and mylib.mli defines the constrained interfaces :
module A = sig ... end
module B = sig ... end
But I have the following two questions. Suppose I pack the objects
files into a cma and cmxa,
1) Is there any performance impact when the client uses functions
from A or B via Mylib ? Does it introduce an indirection ?
2) Don't I lose the benefit of cm(x)a ? I have the impression that
here, even if the client uses only functions from Mylib.A, b.cmo (or
b.cmx) will also be linked in. Is that right ?
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-12-05 14:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-05 10:24 Checking an interface against an implementation Daniel Bünzli
2005-12-05 11:46 ` [Caml-list] " Richard Jones
2005-12-05 14:00 ` Daniel Bünzli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox