Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: [Caml-list] Future of labels
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-04-12 (15:15)
From: Sven LUTHER <luther@d...>
Subject: Re: [Caml-list] How do I define prog1?
On Thu, Apr 12, 2001 at 02:39:39PM +0200, Mattias Waldau wrote:
> 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

The right solution would be :

  let a = <computation of a> in
  let b = <computation of b> in
  prog a b

to evaluate a before b, and vice versa.

or, if both computation of a and b return unit, you could do :



Sven Luther
To unsubscribe, mail  Archives: