Article View: comp.std.c++
Article #269Re: foo() => foo
From: Roland McGrath
Date: Fri, 03 Aug 1990 19:03
Date: Fri, 03 Aug 1990 19:03
33 lines
1584 bytes
1584 bytes
If the reason people want the expression "foo" to mean "foo()" (which I think
is a bad idea, since "foo" already means "&foo"), is to make it possible to
hide whether something is a member or a method, why not instead implicitly
define functions for members?
For example,
class foo
{
public:
int member;
};
would be equivalent to:
class foo
{
public:
int member;
int member(void) { return member; }
};
I don't particularly favor this proposal, but it's better than incompatibly
redefining what a function name by itself means.
My solution to this problem would simply be to have all members private, with
public methods to access them. This is commonly done in Smalltalk (where it is
the only way to do it, since all instance variables are private). It is a bit
more code to write (another line per member), but not a lot.
--
Roland McGrath
Free Software Foundation, Inc.
roland@ai.mit.edu, uunet!ai.mit.edu!roland
Technical Details
Message-ID:
<MCGRATH.90Aug3120318@paris.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!helios.ee.lbl.gov!pasteur!paris.Berkeley.EDU!mcgrathReferences:
<26717@pasteur.Berkeley.EDU> <925@bbxsda.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!helios.ee.lbl.gov!pasteur!paris.Berkeley.EDU!mcgrath From: mcgrath@paris.Berkeley.EDU (Roland McGrath) Newsgroups: comp.std.c++ Subject: Re: foo() => foo Message-ID: <MCGRATH.90Aug3120318@paris.Berkeley.EDU> Date: 3 Aug 90 19:03:18 GMT References: <26717@pasteur.Berkeley.EDU> <925@bbxsda.UUCP> Sender: news@pasteur.Berkeley.EDU Organization: Hackers Anonymous International, Ltd., Inc. (Applications welcome) Lines: 33 X-Local-Date: 3 Aug 90 12:03:18 PDT In-reply-to: scott@bbxsda.UUCP's message of 3 Aug 90 15:33:45 GMT