English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: Question point fixe
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1994-10-19 (08:59)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: Question point fixe
> > Why is it impossible to write:
> > let rec monf = build monf;;
> Because the compiler does not want to know anything about "build"
> (except its type) when it compiles "monf".  Thus it doesn't know
> whether "build" will use its argument or not.  If "build" does use its
> argument, there is no way to make this work.  This is the same as
> writing:
> let rec x = succ x;;

Not quite, because "monf" is a function while "x" above is an integer.

For a function, the compiler could initialize "monf" with
(fun _ -> raise Bottom), then evaluate "build monf" (raising "Bottom"
if "build" applies "monf"), then update the initial value as usual.

I'm not saying the compiler should do that: it's painful to implement
and it breaks a nice property of the current compilation for "let
rec", which is that if a "let rec" definition is accepted, then it
always succeeds at run-time in finding the fixpoint.

I would suggest that Vincent Poirriez either tolerates the efficiency
loss implied by "let rec monf x = build monf x", or uses a reference
to compute the fixpoint himself.

- Xavier Leroy