Browse thread
Re: [Caml-list] Future of labels
-
Yaron M. Minsky
-
Jacques Garrigue
-
Judicael Courant
- Markus Mottl
- kahl@h...
- Chris Hecker
-
Judicael Courant
-
Jacques Garrigue
[
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: | 2001-04-12 (15:22) |
From: | Maxence Guesdon <max@s...> |
Subject: | Re: [Caml-list] How do I define prog1? |
Mattias Waldau a écrit : > > I would like to define a (prog1 a b) which first evaluates a, then b, and > returns the > value of a. (Would be nice if I could have arbitrary number of args.) > > I defined it as > > let prog1 a b = a > > Works well in compiled code, first evaluates a, then b. > However bytecode first evaluates b, then a. > > In this cases, call-by-name would be very nice. > > One obvious solution is to write > > let temp = a in > b; > temp > > but that is much too clumsy. > > /mattias > > ------------------- If you want prog1 to evaluate a then b, you can do let prog1 fa fb = let a = fa () in let _ = fb() in a then call prog1 this way : prog1 (fun () -> a) (fun () -> b); -- Maxence ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr