From: Vincent Cheval <vincheval@wanadoo.fr>
To: caml-list@yquem.inria.fr
Subject: Static Function in Class
Date: Mon, 18 May 2009 05:27:58 +0200 (CEST) [thread overview]
Message-ID: <9493703.159904.1242617278198.JavaMail.www@wwinf1e35> (raw)
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
next reply other threads:[~2009-05-18 3:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-18 3:27 Vincent Cheval [this message]
2009-05-18 4:21 ` [Caml-list] " Jacques Garrigue
[not found] ` <4A10F3DB.9080007@yahoo.it>
2009-05-18 9:25 ` Vincent Cheval
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9493703.159904.1242617278198.JavaMail.www@wwinf1e35 \
--to=vincheval@wanadoo.fr \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox