caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jeremie Dimino <jdimino@janestreet.com>
To: "Armaël Guéneau" <armael.gueneau@ens-lyon.fr>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Custom toplevel and ocamlbuild
Date: Tue, 24 Nov 2015 17:14:02 +0000	[thread overview]
Message-ID: <CANhEzE6oAfptoFUoin5zAui=EN0-NeqTHgN3qO2V6TodPSTYeA@mail.gmail.com> (raw)
In-Reply-To: <5654971F.2070006@ens-lyon.fr>

Did you try adding "Foo" at the beginning of myutop.mltop? foo.cmo
needs to come before myutop_main.cmo and I suppose that ocamlbuild
puts the cmo in the same order as the one specified in the .mltop
unless the dependencies force reordering.

The reason foo.cmo needs to come before is that OCaml run the
initialization code of linked compilation units in the same order they
are specified on the command line and the toplevel can only see
modules that have been initialized.
Myutop_main contains the entry point of the toplevel - i.e. the call
to the interactive loop - so the toplevel doesn't have access to units
that are linked after myutop_main.cmo. That's also the reason why you
can't access Myutop_main from the custom toplevel.

On Tue, Nov 24, 2015 at 4:58 PM, Armaël Guéneau
<armael.gueneau@ens-lyon.fr> wrote:
> Hi list,
>
> I was trying to build a custom toplevel, bundled with my custom
> modules, and encountered a few issues.
>
> Following the last advice given by gasche on this reddit post
> https://www.reddit.com/r/ocaml/comments/3qjs1q/utop_is_a_much_better_toplevel_than_ocaml_if_you/cwisrrj
> I copy-pasted the files from examples/custom-utop, added a foo.ml file
> containing "let x = 3", and added "Foo" at the end of myutop.mltop.
>
> Then, if I compile the custom toplevel using the provided Makefile
> (which simply uses ocamlbuild and the builtin rule for .mltop files, I
> guess), the toplevel produced does not have access to the Foo module.
>
> However, if I manually build using ocamlfind ocamlmktop:
>
>   ocamlfind ocamlmktop -o myutop -thread -linkpkg -package utop foo.cmo
> myutop_main.cmo
>
> this time, it works, and `myutop` has access to Foo.
>
> Is the default ocamlbuild rule for building .mltop files missing some
> option?  Am I doing something wrong?
>
> — Armaël
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs



-- 
Jeremie

  reply	other threads:[~2015-11-24 17:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-24 16:58 Armaël Guéneau
2015-11-24 17:14 ` Jeremie Dimino [this message]
2015-11-24 17:42   ` Armaël Guéneau
2015-11-24 17:48     ` Jeremie Dimino
2015-11-24 17:52       ` Armaël Guéneau

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='CANhEzE6oAfptoFUoin5zAui=EN0-NeqTHgN3qO2V6TodPSTYeA@mail.gmail.com' \
    --to=jdimino@janestreet.com \
    --cc=armael.gueneau@ens-lyon.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;
as well as URLs for NNTP newsgroup(s).