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 UAA28487; Wed, 24 Apr 2002 20:30:28 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA28489 for caml-list@pauillac.inria.fr; Wed, 24 Apr 2002 20:30:28 +0200 (MET DST) 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 PAA20820 for ; Wed, 24 Apr 2002 15:31:19 +0200 (MET DST) Received: from ep09.kernel.pl (ep09.kernel.pl [212.87.11.162]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g3ODVIP14483 for ; Wed, 24 Apr 2002 15:31:18 +0200 (MET DST) Received: (qmail 20309 invoked by uid 566); 24 Apr 2002 13:31:10 -0000 Date: Wed, 24 Apr 2002 15:31:10 +0200 From: Michal Moskal To: Oliver Bandel Cc: caml-list@inria.fr Subject: Re: [Caml-list] Some/None Message-ID: <20020424133110.GA10571@ep09.kernel.pl> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.28i X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Apr 24, 2002 at 02:48:41PM +0200, Oliver Bandel wrote: > How are Some/None defined, what are they good for? This is similar in idea to NULL pointer in C. E.g. struct foo *ptr is NULL iff ptr cannot be assigned any reasonable value of type foo. You can use 'foo option' in ML the same way -- x : foo option is None if no foo is the right value for x. > A small, simple example will help a lot. let head x = match x with | h::_ -> Some h | [] -> None Here if no reasoable value of the head of the list can be returned 'None' is used. I personally use mutable fields in records of option type. They are initially None, and are filled at some step of computations. However this is non-functional/ugly/etc ;) -- : Michal Moskal :::::::: malekith/at/pld.org.pl : GCS {C,UL}++++$ a? !tv : PLD Linux ::::::: Wroclaw University, CS Dept : {E-,w}-- {b++,e}>+++ h ------------------- 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