home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:16002 comp.std.c++:1524
- Newsgroups: comp.lang.c++,comp.std.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: PROPOSAL: Hidden private parts of classes
- Message-ID: <1992Nov10.011938.28327@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Oct30.113234.15010@daimi.aau.dk> <1992Nov7.154137.21910@ucc.su.OZ.AU> <1992Nov9.032225.10320@taumet.com>
- Date: Tue, 10 Nov 1992 01:19:38 GMT
- Lines: 61
-
- In article <1992Nov9.032225.10320@taumet.com> steve@taumet.com (Steve Clamage) writes:
- >maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- >
- >> Having hidden data variables causes the compiler some minor
- >>inconvenience, not knowing the length. However private non-virtual
- >>member functions cause no problems (if they were allowed). These are
- >>IMHO needed so as to be able to write small helper members in
- >>the implementation, I've suggested this be allowed, a suitable
- >>syntax does not suggest itself though.
- >
- >If you mean private non-virtual member functions which don't appear in
- >the class definition, it would cause another language change.
-
- Yes, I propose ad additional keyword 'hidden' as well.
- Hidden is like private, but is truly invisible not just inaccessible.
- Static and non-virtual hidden functions can be defined without
- declaring them in the clas interface, data must be declared in the
- interface (but is still not visible outside the class).
-
- >Overloading is resolved before accessibility is checked. Suppose we have:
- >
- > class X {
- > foo(double); // private
- > public:
- > foo(int);
- > };
- > void bar()
- > {
- > X x;
- > x.foo(2.0); // which foo() ?
- > }
- >
- >This code is in error, since the best match is a private function. The
- >semantics would change if "foo(double)" did not have to appear in the
- >publicly-used class definition; "foo(int)" would be called. Overloading
- >is resolved first precisely to avoid quiet semantic changes based only
- >on access rights.
-
- I know. I do not propose to change 'private', but only add 'hidden'.
- It would even be possible to have two different definitions of hidden
- functions in different modules (thought perhaps not desirable).
- Similar calls in private functions and public ones might resolve
- differently, which is not nice, but neither the deriver nor the public
- will need to cope with this, only the programmer of the class
- implementation.
-
- In anycase there are several situations where one might
- desire something like hidden functions. Often I am implementing
- a class and need a helper member, I do not want this arbitrary
- part of the implementation to be visible or cause recompilation
- of client modules. Such helpers are particularly needed in C++
- which does not allow nested functions. It is possible to write
- non-member static helper functions, but not members.
-
- Perhaps there is a better way to do it.
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-