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 SAA25756; Wed, 24 Apr 2002 18:20:05 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA25880 for ; Wed, 24 Apr 2002 18:20:04 +0200 (MET DST) Received: from hirsch.in-berlin.de (hirsch.in-berlin.de [192.109.42.6]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g3OGK3125532 for ; Wed, 24 Apr 2002 18:20:03 +0200 (MET DST) Received: from hirsch.in-berlin.de (localhost [127.0.0.1]) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with ESMTP id g3OGK2TL007720 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT); Wed, 24 Apr 2002 18:20:03 +0200 Received: (from uucp@localhost) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with UUCP id g3OGK2cs007713; Wed, 24 Apr 2002 18:20:02 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: caml-list@inria.fr Received: from localhost (oliver@localhost) by first.in-berlin.de (8.7.6/8.7.3) with SMTP id RAA03153; Wed, 24 Apr 2002 17:59:17 +0200 Date: Wed, 24 Apr 2002 17:59:16 +0200 (MET DST) From: Oliver Bandel To: Markus Mottl cc: caml-list@inria.fr Subject: Re: [Caml-list] Some/None In-Reply-To: <20020424134116.GB27574@kiefer.ai.univie.ac.at> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 24 Apr 2002, Markus Mottl wrote: > Oliver Bandel schrieb am Mittwoch, den 24. April 2002: > > I have not found any description in the > > Ref-Manual (for 3.01). > > This type is implicitly defined in the "Pervasives"-module as follows: > > type 'a option = None | Some of 'a > > As the name indicates, you can use it to describe optional values, i.e. > you either have "Some value" or you have "None". It has a similar purpose > as NULL-pointers in C, but with the difference that it is perfectly safe > to handle. OK, I see the advantage here: No coredump-problems like in C. [...] > match maybe_data with > | Some data -> (* do something with "data" *) > | None -> (* handle case when no data available *) > > There is no way to accidently access "maybe_data" as if it were "Some > data" even though it is actually "None" - a very common programming > mistake in C. OK, looks like the problem with Unix.ENOENT. > > The option type is really just an ordinary algebraic datatype, which is > useful enough to deserve being defined in the standard library. OK. Ciao, Oliver ------------------- 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