caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: jonathan.roewen@gmail.com
Cc: info@gerd-stolpmann.de, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] The Bytecode Interpreter...
Date: Mon, 24 Oct 2005 15:13:12 +0900 (JST)	[thread overview]
Message-ID: <20051024.151312.52118628.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <ad8cfe7e0510232238t98c5652q9e40530cf3753bee@mail.gmail.com>

> > When one #loads within a toploop, more or less the same happens.
> > However, the toploop is a full compiler, and does not only have the
> > symbol table, but also the current environment, i.e. the set of
> > currently visible types and values with the still-needed parts of their
> > definitions. As far as I know, #load does not modify the environment
> > (because nothing changes - the loaded modules are already in scope when
> > the .cmi file is in the search path).

This is true that #load itself does nothing to the typing environment,
but there is probably a slightly confusing point in that the toplevel
has a not completely static view of its environment. Namely, it
interacts lazily with the filesystem. As a result, the type of a unit
is only fixed the first time its .cmi is loaded. So the toplevel lets
you do strange things such as generating code and loading it on the
fly: you just need to make sure you generate new file names.
This does not negate your point: the toplevel sees its typing
environment as immutable (outside of direct input), and it has no way
to know that any module on the disk is "new".


> Yes, but the bytecode itself is not in the environment, or at least
> not initialised, hence why you need the #load right? Try using Str
> module for instance. Symbols in memory, but that's it.

Sure, but the point is that any code accessing a unit does it assuming
an immutable type for it, that can be verified when loading the
bytecode.
Note that one can do this with Dynlink too: if you load unit A with
dynlink, and unit B later, then unit B can refer to values in unit A.
The only thing the linker doesn't let you do, is to have code that
refers to values that are not yet loaded. And this is true both in the
toplevel and with Dynlink.

> Anyways, my next question is: does the toplevel need dlopen & friends?
> I know dynlink module would, as you stated, it performs relocation and
> all that other stuff.

Yes, sure, it does something similar to dlopen on bytecode. You can
just see the code in topdirs.ml.

Jacques Garrigue


  reply	other threads:[~2005-10-24  6:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-21 10:01 Jonathan Roewen
2005-10-21 11:27 ` David MENTRE
2005-10-21 22:24   ` Jonathan Roewen
2005-10-21 23:49     ` Oliver Bandel
2005-10-22 21:33       ` Jonathan Roewen
2005-10-22  0:32     ` Jon Harrop
2005-10-22  0:39     ` Jacques Garrigue
2005-10-23  1:03   ` Jonathan Roewen
2005-10-23 10:21     ` Gerd Stolpmann
2005-10-24  5:38       ` Jonathan Roewen
2005-10-24  6:13         ` Jacques Garrigue [this message]
2005-10-24  6:48           ` Jonathan Roewen
2005-10-22  0:39 ` Jonathan Roewen
2005-10-26  0:33   ` Jonathan Roewen
2005-10-26  9:56 ` Jonathan Roewen
2005-10-26 10:20   ` Jonathan Roewen
2005-10-27 14:12   ` Damien Doligez
2005-10-28 21:41     ` Jonathan Roewen
2005-10-29 11:29       ` Gerd Stolpmann
2005-10-29 15:22         ` skaller
2005-10-30  0:41           ` Jonathan Roewen
2005-11-10 10:26         ` Damien Doligez

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=20051024.151312.52118628.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@yquem.inria.fr \
    --cc=info@gerd-stolpmann.de \
    --cc=jonathan.roewen@gmail.com \
    /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).