From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: jhw@wetware.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] wish for something like 'restricted' methods
Date: Wed, 23 Mar 2005 14:03:12 +0900 (JST) [thread overview]
Message-ID: <20050323.140312.78769966.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <1b4c73f40a9fe87d2bcf34c14afa1e74@wetware.com>
From: james woodyatt <jhw@wetware.com>
> I'd like to be able to define a method that isn't public, but also
> isn't private. I don't know what to call this method qualification.
> For the purposes of this discussion *only*, I'll pick a proposed word
> to reserve: restricted.
>
> A "restricted" method would be one that may only be invoked within the
> methods of objects constrained to the type of any classtype-def in
> their classtype-definition.
Reading the remainder of your mail, I couldn't understand your notion
of restricted method.
Maybe it would be better if you give an exemple of situation where you
need this new expressiveness, rather than explicitely define a new
notion, as there may be several solutions to your problem.
> Have ideas along these lines been considered or even researched? I
> realize that there are ways to get along without a feature like this,
> and they're not that bad all things considered. (Example: use public
> methods with abstract types in the module signature, and delegate
> through them to private methods with concrete types.) This
> "restricted" method type would just be a convenient way of allowing the
> programmer to express this intent within the language itself.
Jerome Vouillon (the original implementor of the ocaml object system)
wrote a paper about using views to allow arbitrary hiding of methods.
Combining subsumption and binary methods: An object calculus with views
In Proceedings of the 28th ACM Conference on Principles of Programming
Languages, pages 290\u2013303, 2001
This may be related to what you want. However there is no plan to
include views in ocaml.
On the other hand, I have just extended the ocaml type system to allow
the use of private structural types, i.e. abstract types where you
still allow access to some methods.
Then you can write something like this:
module M : sig
type p = private < m: int; .. >
type q = private < g: int; .. >
val new_p : unit -> p
val new_q : p -> q
end = struct
class p = object
method m = 3
method f (q : q) = q#h
end
and q (x : p) = object (self)
method g = x#f (self :> q)
method h = 7
end
let new_p () = new p
let new_q = new q
end
where f and h are "friend" methods.
Jacques Garrigue
next prev parent reply other threads:[~2005-03-23 5:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-22 19:18 extending a functional updater implicitly publicizes sub-updater method? Marc Herbert
2005-03-22 19:56 ` [Caml-list] " Remi Vanicat
2005-03-22 23:34 ` wish for something like 'restricted' methods james woodyatt
2005-03-23 5:03 ` Jacques Garrigue [this message]
2005-03-23 8:22 ` [Caml-list] " james woodyatt
2005-03-30 13:16 ` private methods restricted to self? Marc Herbert
2005-03-31 2:30 ` [Caml-list] " Jacques Garrigue
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=20050323.140312.78769966.garrigue@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@inria.fr \
--cc=jhw@wetware.com \
/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