🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3834

Re: Suggestion to the C++ standard

#3834
From: Micha Berger
Date: Wed, 27 Mar 1996 21:39
75 lines
3187 bytes
Marueli Sunny (sunny@libra.math.tau.ac.il) wrote:
: class foo
: {
: private:
: 	Type Member : read GetMember, write SetMember;
: };

I'm not sure of the point of this syntax, but either way it would be too
limiting. Something that comes up often is where the get method ought
to be public, but the set method shouldn't.

So, we'd have to change the syntax to:
class foo
{
private:
      Type Member : public read GetMember, protected write SetMember;
};

or, since we want to split interface (public or protected) from the internals
we'd want GetMember in the public section, and SetMember in the protected
section, perhaps with syntax like this:
class foo  
{
public:
    Type GetMember : read Member;
protected:
    void SetMember : write Member;
}

Member could be either declared, or figured out as a private member of
type Type. But is this really any better than
class foo {
public:
    Type GetMember { return Member; }
protected:
    void SetMember(const Type& m) { Member = m; }
private:
    Type Member;
}

BTW, I prefer using Type member() and void member(const Type&) as a naming
convention for access functions. Less verbose, but just as clear.


Perhaps a suggestion would have been to allow member v'bles to have a
pair of access modifiers, and allow automatically generated access functions
have each of the pair. For example
class foo
{
public read, protected write:
    Type Member;
}

which automatically generates a v'ble and two access function all of the same
name. The fact that the three have different manglings saves the linker from
ambiguity, and the lack of prototype vs. two different prototypes clears up
compiler issues.
Actually, such a system could force all member variable private, always
generate access functions. We could just take "public:" as shorthand for
"public read, public write:", etc...

Interesting feature, won't happen.


--
Micha Berger 201 916-0287        Help free Ron Arad, held by Syria 3255 days!
AishDas@haven.ios.com                     (16-Oct-86 -  5-Oct-95)
<a href=news:alt.religion.aishdas>Orthodox Judaism: Torah, Avodah, Chessed</a>
<a href=http://haven.ios.com/~aishdas>AishDas Society's Home Page</a>
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Technical Details
Message-ID: <4jc1n9$dvp@news.ios.com>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <4jatnm$s9b@post.tau.ac.il>

Show Full Headers
Complete Article Headers
From: aishdas@haven.ios.com (Micha Berger)
Message-ID: <4jc1n9$dvp@news.ios.com>
X-Original-Date: 27 Mar 1996 18:34:17 GMT
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 27 Mar 96 21:39:10 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Subject: Re: Suggestion to the C++ standard
Organization: AishDas Society
References: <4jatnm$s9b@post.tau.ac.il>
X-Newsreader: TIN [version 1.2 PL2]
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMVm1ieEDnX0m9pzZAQHFDAF/XAA1xR6jm2+e+6odPu4UB9hzHTB+o4+S
 mS+IIfDNSkVhL3lkXXQjWdlXm3O9MRyx
 =n0vb