Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: [Caml-list] Another q about many types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <m.jambon@i...>
Subject: Re: [Caml-list] Another q about many types
On Fri, 15 Feb 2002, Ryan Tarpine wrote:

> Unfortunately, this means that in order to raise an exception with an object
> of type my_object, not only its own object_data but the data of all the
> variables stored in object_ivs must be of the same type.  I've tried making
> the exception type like this:
>   type allowed_exc = [ `PNone | `PInteger of int | `PFloat of float |
> `PString of string ];;
>   exception EError of allowed_exc my_object;;
> to make the type of allowed exceptions somewhat lax.  But, given a single
> ('a my_object), how can I coerce it to an (allowed_exc my_object) if
> possible?  It has to recursively coerce all the variables in object_ivs.
> I've never done coercion at all before.

Try the following

  raise (EError (obj :> allowed_exc my_object))

instead of

  raise (EError obj)


Bug reports:  FAQ:
To unsubscribe, mail  Archives: