Browse thread
[Caml-list] Self type cannot escape class?
- Jeremy Fincher
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jeremy Fincher <tweedgeezer@h...> |
| Subject: | [Caml-list] Self type cannot escape class? |
I'm having a bit of trouble accomplishing what I want to do :) I have two classes, a "poller" class which has methods "add_channel" and "del_channel" to add and remove channels which are polled (with some stuff being done under the hood.) I've got the "channel" class, which I want to be able to accept a poller object in its constructor and call the add_channel function with an argument of "self" in the initializer, and call the del_channel function with an argument of self when it is closed. I am, however, having trouble doing this. I have the two classes defined correctly, and when I don't have the channel class called poller#add_channel or poller#del_channel, it compiles with no errors or warning. When I add the calls to those functions, though (which are necessary for this model to work) I get an error something like this: This expression has type < ... > but is here used with type 'a. Self type cannot escape class. I found a reference to that same error in the manual, section 3.10, but it didn't offer any solutions that worked for me. What do I need to do to make this happen? (Also, as a side note; the channel class has a function defined as "method handle_error () = ()". When not constrained to a type "method handle_error : unit -> unit" the compiler gives this polymorphic type: handle_error : 'a -> 'b. Why is this?) Thanks, Jeremy _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr