From: Pierre Weis <Pierre.Weis@inria.fr>
To: Xavier.Leroy@inria.fr (Xavier Leroy)
Cc: caml-list@inria.fr
Subject: Re: WWW Page of Team PLClub (Re: ICFP programming contest: results)
Date: Sat, 7 Oct 2000 10:35:21 +0200 (MET DST) [thread overview]
Message-ID: <200010070835.KAA28303@pauillac.inria.fr> (raw)
In-Reply-To: <20001006100731.12927@pauillac.inria.fr> from Xavier Leroy at "Oct 6, 100 10:07:31 am"
Xavier explained de Bruijn indices
> Notice that a de Bruijn index is relative to the position of the
> variable reference. Hence the same variable can be referenced by
> different de Bruijn indices depending on context, e.g.
>
> fun x -> print_int x; fun y -> x + y
>
> becomes
> fun -> print_int var0; fun -> var1 + var0
> ^^^^ ^^^^
> this is x this is x too!
>
> De Bruijn indices are interesting for several reasons. One is
> that they totally eliminate any alpha-conversion problems: expressions
> have unique representations, without any need to work modulo renaming of
> bound variables; moreover, substitution of variables by non-closed
> expressions works very well, without any risk of name clashes as in
> the normal, name-based notation.
>
> Another reason is that if you represent the evaluation environment as
> a stack, with each new binding simply pushing the bound value on top,
> then the de Bruijn index for a variable is simply the position of the
> variable's value in the stack, relative to the top of the stack.
> (Substitute "list" for "stack" to deal with persistent, heap-allocated
> environments, e.g. for closures.) This leads to very simple
> translations into abstract machine code.
All this is perfectly true and correct, but in my humble opinion you
forgot to mention the dark side of De Bruijn indices:
- they are perfect for machines but not convenient for human beings!
(We cannot easily consider that the same variable have plenty of
different names in an expression.)
- you have to manipulate indices anyway to mimmick alpha-conversion
when performing beta-reduction (the operation is named the ``lifting''
of De Bruijn indices), and you know that this is at least as difficult
and error prone as performing alpha-renaming. As an example, consider
the parallel (or multiple) beta-reduction: the problem is to calculate
f e1 e2 ... en by substituting e1 e2 ... en, in the body of f,
supposed to be defined by lambda expression with n binders fun -> fun
-> ... -> body. The problem is to perform the reduction in one pass on
the body of f. This operation is trivial if you use a conventional
beta reducer, but it is surprisingly difficult if you use De Bruijn
indices.
- as a consequence of these two properties, debugging code that
manipulates and transforms lambda code in De Bruijn form is just a
nightmare (each time I had to do it, I ended by writing a
pretty-printer that reverts De Bruijn notation to good old names for
variables!)
That's why I consider a ``tour de force'' the Caml Light compiler that
uses De Bruijn indices for the whole language. However, remember the
famous ``De Bruijn wins again!'' leitmotiv we used to ear in the
building when someone was desesperately fighting with wrong indices
generated by the compiler!
Also consider that the Caml Light compiler does not optimize and
symbolycally manipulate programs: that's devoted to the next ``tour de
force'', the Objective Caml optimizing compiler, which does not use
the De Bruijn indices notation for lambda terms...
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/
next prev parent reply other threads:[~2000-10-07 8:35 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-05 10:33 David McClain
2000-10-05 20:20 ` Stefan Monnier
2000-10-06 19:26 ` eijiro_sumii
2000-10-07 8:19 ` automatic translation in Team PLClub ICFP'2000 entry Julian Assange
2000-10-07 16:30 ` eijiro_sumii
2000-10-06 8:07 ` WWW Page of Team PLClub (Re: ICFP programming contest: results) Xavier Leroy
2000-10-07 8:35 ` Pierre Weis [this message]
2000-10-07 9:55 ` Markus Mottl
2000-10-07 10:24 ` Pierre Weis
2000-10-08 21:26 ` John Max Skaller
2000-10-10 10:23 ` Pierre Weis
2000-10-09 5:51 ` Benjamin Pierce
2000-10-09 7:19 ` de Bruijn indices (Re: WWW Page of Team PLClub) Eijiro Sumii
2000-10-10 10:36 ` Pierre Weis
2000-10-10 14:04 ` de Bruijn indices Gerard Huet
2000-10-10 17:29 ` Chet Murthy
2000-10-11 22:35 ` John Max Skaller
-- strict thread matches above, loose matches on Subject: below --
2000-10-05 22:46 WWW Page of Team PLClub (Re: ICFP programming contest: results) David McClain
2000-09-21 7:12 ICFP programming contest: results Xavier Leroy
2000-09-24 3:36 ` Eijiro Sumii
2000-10-04 18:40 ` WWW Page of Team PLClub (Re: ICFP programming contest: results) eijiro_sumii
2000-10-05 21:19 ` malc
2000-10-06 9:46 ` Julian Assange
2000-10-06 19:10 ` eijiro_sumii
2000-10-06 20:13 ` eijiro_sumii
2000-10-06 20:05 ` eijiro_sumii
[not found] ` <200010070759.JAA00538@pauillac.inria.fr>
2000-10-07 16:21 ` eijiro_sumii
2000-10-08 21:06 ` Pierre Weis
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=200010070835.KAA28303@pauillac.inria.fr \
--to=pierre.weis@inria.fr \
--cc=Xavier.Leroy@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