caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Static Function in Class
@ 2009-05-18  3:27 Vincent Cheval
  2009-05-18  4:21 ` [Caml-list] " Jacques Garrigue
       [not found] ` <4A10F3DB.9080007@yahoo.it>
  0 siblings, 2 replies; 3+ messages in thread
From: Vincent Cheval @ 2009-05-18  3:27 UTC (permalink / raw)
  To: caml-list

Hi,

I have a question about Object in Ocaml. I wonder if it's possible to create static function in the definition of a object in Ocaml. Here is a small exemple :

Assume that you have this class definition:

#class test (n:int) =
# object
# val x = n
# method get_x = x
# end;;
#
#let equal (t_1:test) (t_2:test) = t_1#x = t_2#x;;

This class and the function are well defined but I would like not to use the method "get_x" and define my class like that :

#class test (n:int) =
# object
# val x = n
# method equal (t_1:test) (t_2:test) = t_1#x = t_2#x
# end;;

If we were on Java or C++, i should use Static in front of the declaration of "equal". So my question is : Is it possible to do the same thing in OCaml ?

Thank You very much... it's my first mail on this mailing list so I hope it's not a boring question.

Vincent Cheval


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

end of thread, other threads:[~2009-05-18  9:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-18  3:27 Static Function in Class Vincent Cheval
2009-05-18  4:21 ` [Caml-list] " Jacques Garrigue
     [not found] ` <4A10F3DB.9080007@yahoo.it>
2009-05-18  9:25   ` Vincent Cheval

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