caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Diego Olivier FERNANDEZ PONS <diego.fernandez_pons@etu.upmc.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Why + vs +. but "fake" parametric polymorphism for <
Date: Fri, 13 Oct 2006 15:53:37 +0200	[thread overview]
Message-ID: <1160747618.16545.24.camel@localhost.localdomain> (raw)
In-Reply-To: <20061013144605.vvzwfl4pw0kockw8@webmail.etu.upmc.fr>

Am Freitag, den 13.10.2006, 14:46 +0200 schrieb Diego Olivier FERNANDEZ
PONS:
>      Bonjour,
> 
> Quoting Gerd Stolpmann <info@gerd-stolpmann.de>:
> > Well, this is quite easy. The .mli file does not influence code
> > generation. Code is generated when the .ml file is compiled, and it is
> > only _checked_ afterwards if the types match the .mli file. This is
> > simply the logic of the .mli.
> 
> Very well, but why ?

I think the answer is that ocaml uses the model of separate compilation.
That means you can compile the top-level modules separately (in a
certain order) and link them later together. Of course, this implies
that the compilation and code generation steps must be applied in a
certain order. Ocaml is already cleverer than most other implementations
of separate compilation because it allows to defer some parts of code
generation (the so-called cross-module inlining feature).

One can imagine different models. For example, you could do code
generation when a function is _used_, not when the function is seen by
the compiler for the first time. That way, you can always specialize the
function in the generated code to what the types allow. Such a model is
seen as quite problematic, however, because it is unclear how to create
pre-compiled libraries. (In the C++ world often a variation of this
model is used, and is an endless source of problems.)

Of course, you may ask why Ocaml's inlining feature isn't clever enough
to do late specialisation, at least of functions that can be inlined. I
don't know.

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------


  parent reply	other threads:[~2006-10-13 13:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-12  5:18 Carlos Pita
2006-10-12  5:45 ` [Caml-list] " Jacques Garrigue
2006-10-12  5:58   ` Carlos Pita
2006-10-12  6:08     ` Jonathan Roewen
     [not found]       ` <452DF46C.802@fmf.uni-lj.si>
2006-10-12 14:26         ` Carlos Pita
2006-10-13 11:56       ` Diego Olivier FERNANDEZ PONS
2006-10-13 12:14         ` Gerd Stolpmann
2006-10-13 12:46           ` Diego Olivier FERNANDEZ PONS
2006-10-13 13:01             ` Luc Maranget
2006-10-13 13:15               ` Diego Olivier FERNANDEZ PONS
2006-10-13 13:15               ` skaller
2006-10-13 13:36                 ` Luc Maranget
2006-10-13 13:53             ` Gerd Stolpmann [this message]
2006-10-13 14:16               ` Luc Maranget
2006-10-12  5:19 Carlos Pita
2006-10-12  5:41 ` [Caml-list] " Carlos Pita
2006-10-12  5:49   ` Basile STARYNKEVITCH
2006-10-12  5:53   ` Jonathan Roewen
2006-10-12  6:10     ` Carlos Pita

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=1160747618.16545.24.camel@localhost.localdomain \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=diego.fernandez_pons@etu.upmc.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).