From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: patrick@watson.org
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Objects and private methods
Date: Fri, 21 Dec 2001 17:40:35 +0900 [thread overview]
Message-ID: <20011221174035L.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <20011221001434.V91723-100000@fledge.watson.org>
From: Patrick M Doane <patrick@watson.org>
> > You cannot convert something from private to public through a coercion
> > (this is different from forcing it with an annotation). This is
> > because the values are actually different: a private method and a
> > public method have different internal representations.
>
> Are there any papers that I could read over that would give a better sense
> for the internal representations? That might help me understand some of
> these limitations better.
I don't think so, but books like Abadi&Cardelli's Types for Objects
would give you an insight on what is safe and what is not.
> > On the other hand, you can hide a method through coercions.
> >
> > class a_impl = object (self)
> > method get_b = (self :> b)
> > method b = ()
> > end
> > let new_a = (new a_impl :> a)
>
> Thanks! What then are the advantages to using an annotation instead of a
> coercion for signature matching? For example, with a hypothetical syntax
> like this:
>
> class a_impl :> a = object (self)
> method get_b = (self :> b)
> method b = ()
> end
You can only coerce from type to type, not from signature to
signature. Otherwise you would be able to hide a method, and then
redefine it with the same name but another type. Such inheritance
patterns are not type safe, so you are not allowed to hide a public
method at the class level, only at the expression level, where it is
safe.
Jacques Garrigue
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
prev parent reply other threads:[~2001-12-21 8:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-21 3:02 Patrick M Doane
2001-12-21 5:06 ` Jacques Garrigue
2001-12-21 5:29 ` Patrick M Doane
2001-12-21 8:40 ` Jacques Garrigue [this message]
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=20011221174035L.garrigue@kurims.kyoto-u.ac.jp \
--to=garrigue@kurims.kyoto-u.ac.jp \
--cc=caml-list@inria.fr \
--cc=patrick@watson.org \
/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