Re: [Caml-list] Physical counterpart to Pervasives.compare?

2009-08-24 Thread Jean-Christophe Filliâtre
Pascal Cuoq a écrit : >> Elnatan Reisner wrote: >>> Is there something that can complete this analogy: >>> (=) is to (==) as Pervasives.compare is to ___? >>> > The simple solution is to number at creation the objects that you want to > physically compare, using an additional field. You can do tha

Re: [Caml-list] OCamlMakefile, menhir and its --infer option

2009-08-24 Thread Francois Pottier
Hello, On Thu, Aug 06, 2009 at 01:16:35PM +0200, ChoJin wrote: > I have an issue while using OCamlMakefile, menhir and its --infer > option. I don't know if OCamlMakefile properly supports menhir with the --infer option. The simplest solution to your problem would be to use ocamlbuild instead

Re: [Caml-list] Physical counterpart to Pervasives.compare?

2009-08-24 Thread Pascal Cuoq
Pascal Cuoq a écrit : Elnatan Reisner wrote: Is there something that can complete this analogy: (=) is to (==) as Pervasives.compare is to ___? The simple solution is to number at creation the objects that you want to physically compare, using an additional field. Since people are still pa

[Caml-list] lazy vs fun

2009-08-24 Thread Warren Harris
Is there any advantage to using lazy evaluation in ocaml rather than just using thunks to defer evaluation? E.g. let x = lazy (3+4) let y = Lazy.force x vs: let x = fun () -> 3+4 let y = x () Perhaps it's just that the type int lazy_t is more informative than unit -> int? Warren ___

Re: [Caml-list] lazy vs fun

2009-08-24 Thread Jake Donham
On Mon, Aug 24, 2009 at 2:57 PM, Warren Harris wrote: > Is there any advantage to using lazy evaluation in ocaml rather than just > using thunks to defer evaluation? E.g. > > let x = lazy (3+4) > let y = Lazy.force x > > vs: > > let x = fun () -> 3+4 > let y = x () Lazy cells don't just defer, the

Re: [Caml-list] lazy vs fun

2009-08-24 Thread Stéphane Glondu
Warren Harris a écrit : > Is there any advantage to using lazy evaluation in ocaml rather than > just using thunks to defer evaluation? [...] Two things I can think of right now: they are evaluated only once (even if you call Lazy.force several times), and you can do pattern matching with them. >

Re: [Caml-list] lazy vs fun

2009-08-24 Thread Warren Harris
On Aug 24, 2009, at 3:04 PM, Jake Donham wrote: Lazy cells don't just defer, they also memoize the returned value once the cell is forced. Thanks Jake - I guess I overlooked that in the manual. Warren ___ Caml-list mailing list. Subscription mana

Re: [Caml-list] lazy vs fun

2009-08-24 Thread Jake Donham
On Mon, Aug 24, 2009 at 3:15 PM, Warren Harris wrote: >> Lazy cells don't just defer, they also memoize the returned value once >> the cell is forced. > > Thanks Jake - I guess I overlooked that in the manual. Hope you're doing well. Best of luck on the CUFP talk. Jake __

Re: [Caml-list] lazy vs fun

2009-08-24 Thread Martin Jambon
Stéphane Glondu wrote: > Warren Harris a écrit : >> Is there any advantage to using lazy evaluation in ocaml rather than >> just using thunks to defer evaluation? [...] > > Two things I can think of right now: they are evaluated only once (even > if you call Lazy.force several times), and you can

Re: [Caml-list] lazy vs fun

2009-08-24 Thread Martin Jambon
Martin Jambon wrote: > Stéphane Glondu wrote: >> Warren Harris a écrit : >>> Is there any advantage to using lazy evaluation in ocaml rather than >>> just using thunks to defer evaluation? [...] >> Two things I can think of right now: they are evaluated only once (even >> if you call Lazy.force sev

Re: [Caml-list] lazy vs fun

2009-08-24 Thread Warren Harris
On Aug 24, 2009, at 4:11 PM, Martin Jambon wrote: Oops. The following makes it possible for f to be garbage-collected: [...] If I understand correctly, the closure associated with f will be collectable after the lazy_t is forced, whereas before its lifetime would be bound to the lifetim

Re: [Caml-list] lazy vs fun

2009-08-24 Thread rixed
> Oops. > The following makes it possible for f to be garbage-collected: ...? Because the fact that the fun calls f does not count as a reference ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-

RE: [Caml-list] lazy vs fun

2009-08-24 Thread David Allsopp
ri...@happyleptic.org wrote: > > Oops. > > The following makes it possible for f to be garbage-collected: > > ...? > Because the fact that the fun calls f does not count as a reference ? The anonymous function in the second version of Martin's function doesn't "call" [f] (at least directly): imag