From: "Jocelyn Sérot" <Jocelyn.SEROT@univ-bpclermont.fr>
To: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] A question about custom toplevels
Date: Thu, 8 Mar 2018 17:01:37 +0100 [thread overview]
Message-ID: <8ED11F3D-8709-4A15-A889-E507D59B2BAE@univ-bpclermont.fr> (raw)
In-Reply-To: <CADK7aFPW_TSgX-f61upapH1UCBNwim4GGRptB=VUN+_YmwuhZw@mail.gmail.com>
Dear Nicolàs,
Thank for your very clear answer.
I should have guessed this from the fact that the .cmi files were not available indeed ..
Best wishes
Jocelyn
Le 8 mars 2018 à 15:18, Nicolás Ojeda Bär <nicolas.ojeda.bar@lexifi.com> a écrit :
> Dear Jocely,
>
> I do not think this is currently possible.
>
> When you enter a phrase into the toplevel (custom or otherwise), it is
> compiled much the same way as if it had been written in a file and
> passed to ocamlc.
> To do so the compiler needs access to the signature information stored
> in the .cmi files of all referenced modules. This is completely
> independent of whether the code of those modules is linked into the
> toplevel or loaded separately which is what ocamlmktop is about.
>
> Note that it works the same way even for modules of the stdlib. The
> reason "it just works" in that case is because a flag "-I <stdlibdir>"
> is added implicitly. But if you pass the -nostdlib flag to the
> toplevel, this implicit flag is not added, and the toplevel will not
> be able to find the .cmi files of the stdlib in much the same way in
> cannot find foo.cmi.
>
> Best wishes,
> Nicolás
>
> On Thu, Mar 8, 2018 at 9:19 AM, Jocelyn Sérot
> <Jocelyn.Serot@univ-bpclermont.fr> wrote:
>> Hello,
>>
>> I recently stumbled on a problem and am wondering whether it comes from a
>> misunderstanding or a bad usage.
>>
>> When a custom toplevel is built using the [ocamlmktop] program, it seems
>> that the modules which are « included » must be present in the path when the
>> so-built toplevel is executed afterwards.
>>
>> For example, suppose that directory « bar » contains a file foo.ml, with,
>> let say the definition « let v=100 ».
>> Then, making
>>
>> ocamlfind ocamlc -c -o foo.cmo foo.ml
>> ocamlfind ocamlc -a -o foo.cma foo.cmo
>> ocamlfind ocamlmktop -o foo.top foo.cma
>>
>> creates foo.top, which, when executed, behaves has expected.
>>
>> $ ./foo.top
>> OCaml version 4.06.0
>>
>> # Foo.v;;
>> - : int = 100
>>
>> But, when trying to execute foo.top from another directory, for ex from
>> ../bar, i get the following error :
>>
>> $ ./bar/foo.top
>> OCaml version 4.06.0
>>
>> # Foo.v;;
>> Error: Unbound module Foo
>>
>> The error disappears if i add option « -I ./bar » when lauching foo.top (or,
>> equivently execute the directive « #directory ./bar »).
>>
>> Is there a way to build a « self-contained » custom toplevel which could be
>> executed without any explicit reference to the modules it included at
>> creation ?
>>
>> Jocelyn
>>
>> ps : i tried the -custom option but, not surprisingly, it does not solve the
>> pb since it only refers to external C code.
next prev parent reply other threads:[~2018-03-08 16:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-08 8:19 Jocelyn Sérot
2018-03-08 14:18 ` Nicolás Ojeda Bär
2018-03-08 16:01 ` Jocelyn Sérot [this message]
2018-03-08 17:28 ` Alain Frisch
2018-03-12 5:50 ` Oleg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8ED11F3D-8709-4A15-A889-E507D59B2BAE@univ-bpclermont.fr \
--to=jocelyn.serot@univ-bpclermont.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox