Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: Caml <caml-list@inria.fr>
Subject: Re: [Caml-list] Functors, inlining and Camlp4
Date: Tue, 9 Oct 2001 19:10:13 +0200	[thread overview]
Message-ID: <20011009191013.B5072@verdot.inria.fr> (raw)
In-Reply-To: <0110091754320I.05684@beige>; from barnier@recherche.enac.fr on Tue, Oct 09, 2001 at 05:54:32PM +0200

Hi,

> In one of his answer, Xavier suggested to "manually" inline critical
> code, which, I guess, means to withdraw the functors and
> duplicate/specialize the module code. But I'm quite reluctant to
> mess it up this way. I hardly know anything about Camlp4, but I was
> wondering if it would be possible to automate this tedious task by
> preprocessing the sources

1/ First answer...

Mmmm... Seen like that, I don't think that Camlp4 can help. Inlining
supposes to know what a definition of a variable (or a function) is,
what is not supposed to be the job of a syntactic preprocessor. For
it, when you write:
     let x = y + 1

it is interpreted (in Camlp4) as "the specific construction 'let'
which has its specific syntax". That's all.

The fact that "let" corresponds to a binding is semantics, not
syntax. In particular, such an imaginary Camlp4 inlining could not be
applied between two compilation units (i.e. between two files). If you
write "Foo.xxx" in file bar.ml, Camlp4 just ignores what this "xxx"
is and where Foo comes from.

Well, you could imagine to do some semantics just inside a file, but
I am not sure that it would be Camlp4 politically correct.

2/ Second answer...

In general, in Camlp4, syntax extensions are "meta" relative to the
program. To inline x, a correct usage is not to write:
     let x = y + 1

and hope that "x" could be inlined, but rather write a file defining
x as a macro for y. This file should be separately compiled and the
resulting cmo file given as parameter to Camlp4 command line.

An improvement could be to add a syntax extension to do macros in
general. I implemented that some time ago (but it is not distributed).
If people ask for it, I can add it in the next version of Camlp4/OCaml.
With this syntax extension you can write:
     DEFMACRO x = y + 1

and every x is inlined into "y + 1" in the current file; notice that
in this case, there is no definition of x; the DEFMACRO is a directive
to the preprocessor.

(in this system, macros can have parameters)

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


      reply	other threads:[~2001-10-09 17:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-09 15:54 Nicolas barnier
2001-10-09 17:10 ` Daniel de Rauglaudre [this message]

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=20011009191013.B5072@verdot.inria.fr \
    --to=daniel.de_rauglaudre@inria.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