From: Nick Name <nick.name@inwind.it>
To: Mirko Aigner <Mirko.Aigner@alcatel.de>, caml-list@inria.fr
Subject: Re: [Caml-list] prevent more than one object
Date: Wed, 2 Jul 2003 18:43:56 +0200 [thread overview]
Message-ID: <20030702184356.15d48330.nick.name@inwind.it> (raw)
In-Reply-To: <3F0304DF.1010300@alcatel.de>
On Wed, 02 Jul 2003 18:14:23 +0200
Mirko Aigner <Mirko.Aigner@alcatel.de> wrote:
>
> The problem is the class is still public and instances can be build,
> any way to prevent this ?!
I would make the class private in the module and supply only access
functions; if you need it to be a class you should expose only the class
type, but there is Oo.copy so your value will never be granted unique.
Try this
module M : sig
class type singleton = object
method f : int
end
val x : singleton
end =
struct
class singleton = object
method f = 0
end
let x = new singleton
end
You can't create a new singleton with "new" but still can do that with
Oo.copy M.x. It is better to completely hide the type if you can, as in
module M : sig
type singleton
val x : singleton
end = struct ...
Vincenzo
--
Ho dato al mio dolore la forma di parole abusate
che mi prometto di non pronunciare mai più
[CSI]
-------------------
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
next prev parent reply other threads:[~2003-07-02 16:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-02 16:14 Mirko Aigner
2003-07-02 16:43 ` Nick Name [this message]
2003-07-03 11:20 ` John Max Skaller
2003-07-03 11:36 ` Mirko Aigner
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=20030702184356.15d48330.nick.name@inwind.it \
--to=nick.name@inwind.it \
--cc=Mirko.Aigner@alcatel.de \
--cc=caml-list@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