caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Open class types
@ 2008-07-01 13:53 SerP
  2008-07-01 15:02 ` [Caml-list] " Tiphaine Turpin
  2008-07-01 15:14 ` Virgile Prevosto
  0 siblings, 2 replies; 3+ messages in thread
From: SerP @ 2008-07-01 13:53 UTC (permalink / raw)
  To: caml-list



class type location_t =
  object
    method a: int;
    method b: string;
  end;

class type session_t =
  object
    method id:int;
    method location: #location_t;
  end;

value check_session (session:#session_t) = begin
  print_int session#id;
  print_int session#location#a;
  print_string session#location#b;
end;

class location =
  object
    method a = 1;
    method b = "b";
    method c = ["a";"b"];
  end;

class session =
  object  
    value location = new location;
    method id = 1;
    method location = location;
  end;

value _ =
  let s = new session in
  check_session s;
====================================
Error: This expression has type session = < id : int; location : location >
       but is here used with type
         #session_t as 'a = < id : int; location : 'b. #location_t; .. >
       Type location = < a : int; b : string; c : string list >
       is not compatible with type 'b
       The second object type has no method c
--------------------------------------------
But,
    value check_session (session:< id : int; location : < a : int; b : 
string; .. >; .. >) = begin .....

Compiled properly.

Please help. Is exists any way to define open class type like inline 
type definition.
Write every function with inline type definition in mli files is terrible.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-01 15:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-01 13:53 Open class types SerP
2008-07-01 15:02 ` [Caml-list] " Tiphaine Turpin
2008-07-01 15:14 ` Virgile Prevosto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).