Version française
Home     About     Download     Resources     Contact us    
Browse thread
Static Function in Class
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Vincent Cheval <vincheval@w...>
Subject: Static Function in Class
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