caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* accessing values of a class from another instance
@ 2005-12-08 19:20 Shaddin Doghmi
  2005-12-08 21:17 ` [Caml-list] " Virgile Prevosto
  0 siblings, 1 reply; 2+ messages in thread
From: Shaddin Doghmi @ 2005-12-08 19:20 UTC (permalink / raw)
  To: caml-list

It seems instance variables of an object are not accessible from other
objects that are instances of the same class. What is a nice way to
simulate this functionality? I would like to avoid accessor methods for
the class variables since I want to hide the variables from anything
outside the class.


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

* Re: [Caml-list] accessing values of a class from another instance
  2005-12-08 19:20 accessing values of a class from another instance Shaddin Doghmi
@ 2005-12-08 21:17 ` Virgile Prevosto
  0 siblings, 0 replies; 2+ messages in thread
From: Virgile Prevosto @ 2005-12-08 21:17 UTC (permalink / raw)
  To: caml-list

Hello,

2005/12/8, Shaddin Doghmi <shaddin@mitre.org>:
> It seems instance variables of an object are not accessible from other
> objects that are instances of the same class. What is a nice way to
> simulate this functionality? I would like to avoid accessor methods for

A possibility is to use the module system and let your instance
variable and the corresponding accessor method have an abstract type:
this way, you'll still be able to call the method outside of the
module, but you won't be able to use its result. This is described
here:
http://caml.inria.fr/pub/docs/manual-ocaml/manual005.html#ss:friends

Of course, one could probably think of more sophisticated interfaces
for the module, where you would for instance export only a class type
where the accessor method
itself is hidden and a constructor function that performs at the same
time a 'new' and a coercion to this class type. I've never played with
that, though.
--
E tutto per oggi, a la prossima volta
Virgile


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

end of thread, other threads:[~2005-12-08 21:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-08 19:20 accessing values of a class from another instance Shaddin Doghmi
2005-12-08 21:17 ` [Caml-list] " 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).