* Including code from a .cm[ox] into another .cm[ox]
@ 2009-11-12 12:16 Guillaume Yziquel
2009-11-12 12:41 ` [Caml-list] " Philippe Veber
[not found] ` <721f7f5a0911120441h7706cd02ud9b6b993532b88f5@mail.gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Guillaume Yziquel @ 2009-11-12 12:16 UTC (permalink / raw)
To: caml-list
Hello.
Imagine I have a file named a.ml containing
> module C = struct
> include B
> end
and a file named b.ml containing the code
> let f x = x + 1
When I compile everything to .cmo files, I cannot load a.cmo from the
toplevel without loading b.cmo beforehand.
Is there a way to make the 'include B' statement to include the code of
the B module in the C submodule directly so that it is not required to
load the b.cmo file before loading the a.cmo file?
That would be extremely useful to me...
All the best,
--
Guillaume Yziquel
http://yziquel.homelinux.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Including code from a .cm[ox] into another .cm[ox]
2009-11-12 12:16 Including code from a .cm[ox] into another .cm[ox] Guillaume Yziquel
@ 2009-11-12 12:41 ` Philippe Veber
[not found] ` <721f7f5a0911120441h7706cd02ud9b6b993532b88f5@mail.gmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: Philippe Veber @ 2009-11-12 12:41 UTC (permalink / raw)
To: guillaume.yziquel; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 2595 bytes --]
Hi
maybe you can have a look at findlib and its #require statement. For
instance, pxp (xml related library) depends on many cma, but everything
loads automagically when invoking #require :
Objective Caml version 3.11.1
# #use "topfind";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
- : unit = ()
# #require "pxp";;
/home/pveber/usr/lib/godi/lib/ocaml/pkg-lib/pcre: added to search path
/home/pveber/usr/lib/godi/lib/ocaml/pkg-lib/pcre/pcre.cma: loaded
/home/pveber/usr/lib/godi/lib/ocaml/std-lib/unix.cma: loaded
/home/pveber/usr/lib/godi/lib/ocaml/pkg-lib/netsys: added to search path
/home/pveber/usr/lib/godi/lib/ocaml/pkg-lib/netsys/netsys.cma: loaded
/home/pveber/usr/lib/godi/lib/ocaml/pkg-lib/netstring: added to search path
[...]
/home/pveber/usr/lib/godi/lib/ocaml/pkg-lib/pxp-ulex-utf8/pxp_ulex_link_utf8.cmo:
loaded
/home/pveber/usr/lib/godi/lib/ocaml/pkg-lib/pxp: added to search path
# Pxp_document.liquefy;;
- : ?omit_end:bool ->
?omit_positions:bool ->
(< clone : 'a; node : 'a Pxp_document.node;
set_node : 'a Pxp_document.node -> unit; .. >
as 'a)
Pxp_document.solid_xml -> 'b -> Pxp_types.event option
= <fun>
hth,
ph.
2009/11/12 Guillaume Yziquel <guillaume.yziquel@citycable.ch>
> Hello.
>
> Imagine I have a file named a.ml containing
>
> module C = struct
>> include B
>> end
>>
>
> and a file named b.ml containing the code
>
> let f x = x + 1
>>
>
> When I compile everything to .cmo files, I cannot load a.cmo from the
> toplevel without loading b.cmo beforehand.
>
> Is there a way to make the 'include B' statement to include the code of the
> B module in the C submodule directly so that it is not required to load the
> b.cmo file before loading the a.cmo file?
>
> That would be extremely useful to me...
>
> All the best,
>
> --
> Guillaume Yziquel
> http://yziquel.homelinux.org/
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
[-- Attachment #2: Type: text/html, Size: 3912 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Including code from a .cm[ox] into another .cm[ox]
[not found] ` <4AFC0515.5050306@citycable.ch>
@ 2009-11-12 13:35 ` Philippe Veber
2009-11-12 14:16 ` Guillaume Yziquel
0 siblings, 1 reply; 4+ messages in thread
From: Philippe Veber @ 2009-11-12 13:35 UTC (permalink / raw)
To: guillaume.yziquel; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 2109 bytes --]
You're right this is a linking issue and now the question is at which level
you want to "link" your code. I do not see the point of including a cmo in
another like you describe : i believe there are simpler and mainstream
options. Maybe I miss some details about your problem ? Using findlib to
help the linker is one way to do it, but if you insist on loading a single
module then you have two other options :
- code inclusion -> m4, camlmix, camlp4 or any preprocessor (not that ugly,
but still)
- the -pack option for combining several cmo in a single one (but then all
your modules are included in a "toplevel" module)
sorry if i still didn't get your problem ;o).
ph.
2009/11/12 Guillaume Yziquel <guillaume.yziquel@citycable.ch>
> Philippe Veber a écrit :
>
> Hi
>>
>> maybe you can have a look at findlib and its #require statement. For
>> instance, pxp (xml related library) depends on many cma, but everything
>> loads automagically when invoking #require :
>>
>
> No, no, no... this is not the issue at all. My issue is not about loading
> stuff with findlib, it's about including a .cmo into another .cmo. I'd like
> to create a .cma with only a.ml, and not containing b.ml.
>
> It's not a toplevel issue, but a 'linking' issue.
>
> Thanks anyway.
>
> Guillaume.
>
>
>
>
> 2009/11/12 Guillaume Yziquel <guillaume.yziquel@citycable.ch>
>>
>> Hello.
>>>
>>> Imagine I have a file named a.ml containing
>>>
>>> module C = struct
>>>
>>>> include B
>>>> end
>>>>
>>>> and a file named b.ml containing the code
>>>
>>> let f x = x + 1
>>> When I compile everything to .cmo files, I cannot load a.cmo from the
>>> toplevel without loading b.cmo beforehand.
>>>
>>> Is there a way to make the 'include B' statement to include the code of
>>> the
>>> B module in the C submodule directly so that it is not required to load
>>> the
>>> b.cmo file before loading the a.cmo file?
>>>
>>> That would be extremely useful to me...
>>>
>>> All the best,
>>>
>>> --
>>> Guillaume Yziquel
>>> http://yziquel.homelinux.org/
>>>
>>
[-- Attachment #2: Type: text/html, Size: 3428 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Including code from a .cm[ox] into another .cm[ox]
2009-11-12 13:35 ` Philippe Veber
@ 2009-11-12 14:16 ` Guillaume Yziquel
0 siblings, 0 replies; 4+ messages in thread
From: Guillaume Yziquel @ 2009-11-12 14:16 UTC (permalink / raw)
To: Philippe Veber; +Cc: caml-list
Philippe Veber a écrit :
> You're right this is a linking issue and now the question is at which level
> you want to "link" your code. I do not see the point of including a cmo in
> another like you describe : i believe there are simpler and mainstream
> options. Maybe I miss some details about your problem ? Using findlib to
> help the linker is one way to do it, but if you insist on loading a single
> module then you have two other options :
> - code inclusion -> m4, camlmix, camlp4 or any preprocessor (not that ugly,
> but still)
> - the -pack option for combining several cmo in a single one (but then all
> your modules are included in a "toplevel" module)
> sorry if i still didn't get your problem ;o).
> ph.
You're getting my problem right. I'm working on the OCaml-R binding of
Maxence Guesdon.
The thing is, I have a r.ml file, where all the binding work is done.
However, in order to launch the shared library containing the code of
the R interpreter, some environment variables must be set up first.
Therefore I have a small R script, based on Dirk Eddelbuettel's littler
software, that generates an .ml file, rstdenv.ml, containing the
environment variables that need to be set up correctly.
Maybe it's trying to be a bit too pretty, but I do not like the name
Rstdenv for a module. I'd rather have R.Standard.env...
So I'm looking for a way to include a module as a submodule, without
having to link it to rstdenv.cmo, which I really do not want to be
available from the r.cma archive.
That's why I was wondering if there is a clean, camlish way, to
link-substitute code from one .cmo into another .cmo...
The -pack option is clearly overkill, camlp4 seems overkill too, m4 is
ugly, do not know camlmix. There's also a package from Gerd Stolpmann,
xstrp4 or something like that which could be useful. But as I want to
minimise dependencies on extra stuff, I was wondering if there was an
out-of-box obscure compiling option to do so.
All the best,
Guillaume Yziquel.
> 2009/11/12 Guillaume Yziquel <guillaume.yziquel@citycable.ch>
>
>> Philippe Veber a écrit :
>>
>> Hi
>>> maybe you can have a look at findlib and its #require statement. For
>>> instance, pxp (xml related library) depends on many cma, but everything
>>> loads automagically when invoking #require :
>>>
>> No, no, no... this is not the issue at all. My issue is not about loading
>> stuff with findlib, it's about including a .cmo into another .cmo. I'd like
>> to create a .cma with only a.ml, and not containing b.ml.
>>
>> It's not a toplevel issue, but a 'linking' issue.
>>
>> Thanks anyway.
>>
>> Guillaume.
>>
>>
>>
>>
>> 2009/11/12 Guillaume Yziquel <guillaume.yziquel@citycable.ch>
>>> Hello.
>>>> Imagine I have a file named a.ml containing
>>>>
>>>> module C = struct
>>>>
>>>>> include B
>>>>> end
>>>>>
>>>>> and a file named b.ml containing the code
>>>> let f x = x + 1
>>>> When I compile everything to .cmo files, I cannot load a.cmo from the
>>>> toplevel without loading b.cmo beforehand.
>>>>
>>>> Is there a way to make the 'include B' statement to include the code of
>>>> the
>>>> B module in the C submodule directly so that it is not required to load
>>>> the
>>>> b.cmo file before loading the a.cmo file?
>>>>
>>>> That would be extremely useful to me...
>>>>
>>>> All the best,
>>>>
>>>> --
>>>> Guillaume Yziquel
>>>> http://yziquel.homelinux.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-11-12 14:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-12 12:16 Including code from a .cm[ox] into another .cm[ox] Guillaume Yziquel
2009-11-12 12:41 ` [Caml-list] " Philippe Veber
[not found] ` <721f7f5a0911120441h7706cd02ud9b6b993532b88f5@mail.gmail.com>
[not found] ` <4AFC0515.5050306@citycable.ch>
2009-11-12 13:35 ` Philippe Veber
2009-11-12 14:16 ` Guillaume Yziquel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox