caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Five Questions about Objects
@ 2002-07-13 13:42 Oleg
  2002-07-14  0:58 ` YAMAGATA yoriyuki
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Oleg @ 2002-07-13 13:42 UTC (permalink / raw)
  To: caml-list

Hi

A few questions on objects:

1) Why does the following code define a polymorphic class

 class point a b = 
    object 
      val x = a
      val y = b
    end;;

but adding "method get () = (x, y)" results in type errors only resolvable by 
specifying types with "class ['a, 'b] point (a:'a) (b:'b)" ? Why doesn't 

 class point a b = 
    object 
      val x = a
      val y = b
      method get () = (x, y)
    end;;

give me a polymorphic class?

2) What is the point of "class" and "new" keywords? How are they better than 
"let" ? E.g.

let point a b = 
  object
    val x = a
    val y = b
    method get () = (x, y)
  end;;

let my_point = point 3 7;; 
let many_float_points = Array.make 100 (point 4.0 3.0);;
?

3) Is it possible to access object datafields directly or only through 
methods?

4) Can I construct an object that the following function f would accept?
# let f a = a#m1 (); a#b#m2 ();;
val f : < b : < m2 : unit -> 'a; .. >; m1 : unit -> 'b; .. > -> 'a = <fun>

I tried the obvious (to me) and it doesn't work. What is the precedence and 
associativity of #?

5) What is the current state of marshalling objects? Is Jacques's patch going 
to be used in the upcoming O'Caml version or is it too untested? 

Thanks
Oleg
-------------------
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


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

end of thread, other threads:[~2002-07-20 15:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-13 13:42 [Caml-list] Five Questions about Objects Oleg
2002-07-14  0:58 ` YAMAGATA yoriyuki
2002-07-14  2:41   ` Brian Smith
2002-07-20 15:46     ` YAMAGATA yoriyuki
2002-07-14  8:58   ` Alain Frisch
2002-07-14  9:38     ` Jacques Garrigue
2002-07-14 10:23       ` William Lovas
2002-07-14  3:26 ` Jacques Garrigue
2002-07-14 15:47 ` Xavier Leroy
2002-07-16  4:48   ` Oleg
2002-07-16  4:49   ` Oleg

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).