to big guys: a modest feature request
1. Per component access level. Say I would like to have a possibility
to write a class definition as
class Aaa {
public void getFoo() const { return foo; }
protected void setFoo(int val) { foo = val; }
private int foo;
};
public:/protected:/private: could be still used to declare default
access level, so existing code will compile without problems and
people who like the current style can continue to use it and there is
an unambiguous resolution for any combination of styles. Also It will
help readability to have all these new keywords to be of the same
length.
It seems that an alternative form would be also acceptable (if not
preferable).
class Aaa {
void getFoo() const public { return foo; }
void setFoo(int val) protected { foo = val; }
int foo; // private is the default and there are no modifiers for
data members
};
2. Built-in properties
I would like to have a possibility for a following definition
class Aaa {
{
....
};
class Bbb
{
public:
const Aaa& funcA() const property foo;
Aaa& funcB(const &Aaa other) property foo;
int funcC() const property bar;
int funcD(int other) property bar;
};
So
Bbb.bbb;
std::cout << bbb.foo << " " << bbb.bar std::endl;
will simply call Bbb::funcA(); and Bbb::funcC()
and
Bbb other;
bbb.foo = other;
bbb.bar = 5;
will simply call Bbb::funcB(other) and Bbb::funcD(5)
And it will be fine to have a very limited functionality: only access
to a value and an assignment operator, no references/pointers/read-
modify-writes. So, it is OK with me if the compiler will bark on
bbb.bar += 5;
I know it could be done with templates, but for me it is way more
cumbersome than the traditional combination of accessor/modifier
methods.
I suppose these two extensions are trivial to implement, would not
break any existing code and would not require any changes from
programmers who do not want to use them.
At least for me these two features will remove major annoyances when
writing c++ code.
Thanks,
Alex
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]