From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA04755; Mon, 9 Sep 2002 17:00:00 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA05156 for ; Mon, 9 Sep 2002 16:59:59 +0200 (MET DST) Received: from laurelin.dementia.org ([208.167.88.73]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g89Exw903140; Mon, 9 Sep 2002 16:59:58 +0200 (MET DST) Received: by laurelin.dementia.org (Postfix, from userid 1001) id 991FA70D2; Mon, 9 Sep 2002 11:00:31 -0400 (EDT) To: Alessandro Baretta Cc: Xavier Leroy , Ocaml Subject: Re: [Caml-list] Has laziness changed type? References: <3D7A7C8B.9070901@baretta.com> <20020909162320.D1781@pauillac.inria.fr> <3D7CB742.5030908@baretta.com> From: John Prevost Date: 09 Sep 2002 11:00:31 -0400 (62.536 UMT) In-Reply-To: <3D7CB742.5030908@baretta.com> Message-ID: <86admrus1c.fsf@laurelin.dementia.org> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >>>>> "ab" == Alessandro Baretta writes: ab> This is a pity, in a way, but not really a big problem. I ab> often need to check whether a given lazy value corresponds ab> computes a meaningful value or raises an exception. To do this ab> I had code like the following ... ab> This is not terribly useful when you have to match against ab> only one lazy value, but the situation is different when you ab> have a tuple of lazy values, and need to perform different ab> actions depending on which subset of them computes a ab> meaningful value. What's wrong with: try (* do something with *) (Lazy.force foo) with _ -> try (* do something with *) (Lazy.force bar) with _ -> try (* do something with *) (Lazy.force doh) with _ -> (* fallback code *) or let lf x = try Some (Lazy.force x) with _ -> None match (lf a, lf b, lf c, lf d) with ... or even type 'a result = Value of 'a | Exception of 'a let lf x = try Value (Lazy.force x) with e -> Exception e ... The change to the lazy datatype means you have to do a little extra effort if you want to maintain this kind of information. But it's not really a huge deal. John. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners