2445Re: "ocaml_beginners":: A question about "option"
- Aug 1 9:58 AMI found there are codes as follows:
let outChannel : out_channel option ref = ref None
let mergedChannel : out_channel option ref = ref None
Here, "option" is not used in the 'a option form. Does
it mean tha outChannel and mergedChannel are two weak
pointer to references, and these two referenced can be
reclaimed by the garbage collector at any time?
--- Martin Jambon <martin_jambon@...> wrote:
> On Sat, 31 Jul 2004, Andy Yang wrote:__________________________________________________
> > Hi, all
> > Do you know where I can find more introduction on
> > keyword "option" in Ocaml?
> > Basically, option is defined as follows:
> > type 'a option = None | Some of 'a;
> > And I found some codes as follows:
> > class backup
> > object ('a)
> > val mutable copy : 'a option
> > method ...
> > end;;
> > If it means a weak pointer, what will happen if
> > garbage collector reclaims the memory?
> 'a option is a predefined type, which is absolutely
> not magic and
> certainly not a keyword.
> You could have defined it by yourself, but this one
> is predefined in the
> core library of OCaml.
> Normally, this type is used to distinguish between
> something that has been
> defined or specified (Some x) and something which is
> undefined (None).
> In C, you could use the NULL pointer instead of a
> valid pointer to express
> this, but in OCaml you will never have the chance to
> manipulate invalid
> data such as an invalid pointer or an uninitialized
> Have a look at the chapter 3 of Richard Jones'
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
- << Previous post in topic Next post in topic >>