Browse thread
Metaprogramming features
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2008-10-06 (23:16) |
From: | Jon Harrop <jonathandeanharrop@g...> |
Subject: | Re: [Caml-list] Re: Metaprogramming features |
On Monday 06 October 2008 17:46:49 Chung-chieh Shan wrote: > Jon Harrop <jonathandeanharrop@googlemail.com> wrote in article <200810061656.42903.jon@ffconsultancy.com> in gmane.comp.lang.caml.inria: > > Exactly. The difference is (only) the performance characteristics. > > To the contrary, that is not the only difference; the timing of > side effects (including non-termination and exceptions) can also be > different. We give an example at the beginning of our Section 2. I don't follow. Your paper translates the following staged function: let power7 : int -> int = .! .<fun x -> .~(Printf.printf "power\n"; power 7 .<x>.)>.;; into this: let npower7 = (fun () -> fun x -> (printf "power\n"; npower 7 (fun () -> x)) ()) ();; and notes that the result is different because the former calls printf immediately whereas the latter defers. Surely the discrepancy is because the translation should be: let npower7 = let e = printf "power\n"; npower 7 (fun () -> x) in (fun () -> fun x -> e ()) ();; because escaped code is always evaluated before the brackets that surround it, so it needs to be hoisted out of the "fun () -> ..."? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e