caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re:  Question point fixe
@ 1994-10-18 19:17 Damien Doligez
  1994-10-19  8:59 ` Xavier Leroy
  0 siblings, 1 reply; 3+ messages in thread
From: Damien Doligez @ 1994-10-18 19:17 UTC (permalink / raw)
  To: Pierre.Weis, caml-list

>From: Vincent Poirriez
>
>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;;




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question point fixe
  1994-10-18 19:17 Question point fixe Damien Doligez
@ 1994-10-19  8:59 ` Xavier Leroy
  0 siblings, 0 replies; 3+ messages in thread
From: Xavier Leroy @ 1994-10-19  8:59 UTC (permalink / raw)
  To: Damien Doligez; +Cc: Pierre.Weis, caml-list

> > 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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Question point fixe
@ 1994-10-18 10:42 Pierre Weis
  0 siblings, 0 replies; 3+ messages in thread
From: Pierre Weis @ 1994-10-18 10:42 UTC (permalink / raw)
  To: caml-list

From: Vincent Poirriez
Date: Tue, 18 Oct 94 09:43:00 +0100
To: caml-list@pauillac.inria.fr
Subject: Question point fixe


Ci-dessous une question dont j'ai oublie' la reponse:

Pourquoi n'a t'on pas le droit d'e'crire:

let build f =
 let g x = expr       (* ou` l'on fait appel a` f *)
  in
  function y -> expr' (* ou` l'on fait appel a` g *)
;;
let rec monf = build monf;;

L'intere^t de cette e'criture serait d'effectuer les 
calculs possibles par l'application partielle alors que
l'ecriture autorise'e:
 let rec monf x = build monf x;;
ne les effectue pas

Vincent
(Vincent.Poirriez@inria.fr)

(*I Hope my english isn't too bad*)   
Here after, a question that I don't remember the answer:

Why is it impossible to write:
let build f =
 let g x = expr       (* where f is called *)
  in
  function y -> expr' (* where g is called *)
;;
let rec monf = build monf;;

The interest of such a definition is to perform some
calculus in the partial application. These calculus
are not performed in the following allowed definition:
 let rec monf x = build monf x;;

Vincent
(Vincent.Poirriez@inria.fr)




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1994-10-19  9:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-10-18 19:17 Question point fixe Damien Doligez
1994-10-19  8:59 ` Xavier Leroy
  -- strict thread matches above, loose matches on Subject: below --
1994-10-18 10:42 Pierre Weis

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).