R
Russell Reagan
I think compiler enforced restrictions upon data and functions are a good
thing, as it reduces the mental complexity of a program.
I ask the question: Could the public, protected, and private access
descriptors be improved upon?
I think allowing a class to declare read, write, and execute permissions for
other classes and functions to its own variables and functions (much like
the unix file system, and access control lists) would be a better
alternative to only having public and private.
An example: If class A only needs to be able to read one variable from class
B, then class B can give class A read access to that single variable. In
C++, you would either have to make class A a friend of B, giving it access
to everything, or you would have to write a public access routine, giving
read access to everyone. I think there should be a happy medium between "one
gets access to all" (friend), or "all get access to one" (public member
function).
I think this would make code more intellectually managable, more solid, and
more robust, and it could introduce new optimization possibilities for the
compiler.
First, am I overlooking any way to accomplish this greater level of
restriction in current standard C++?
Second, would this actually be an improvement? I've never created a
programming language, so I could be overlooking important issues.
Finally, does a language already exist that has more strict restrictions
upon data and functions?
thing, as it reduces the mental complexity of a program.
I ask the question: Could the public, protected, and private access
descriptors be improved upon?
I think allowing a class to declare read, write, and execute permissions for
other classes and functions to its own variables and functions (much like
the unix file system, and access control lists) would be a better
alternative to only having public and private.
An example: If class A only needs to be able to read one variable from class
B, then class B can give class A read access to that single variable. In
C++, you would either have to make class A a friend of B, giving it access
to everything, or you would have to write a public access routine, giving
read access to everyone. I think there should be a happy medium between "one
gets access to all" (friend), or "all get access to one" (public member
function).
I think this would make code more intellectually managable, more solid, and
more robust, and it could introduce new optimization possibilities for the
compiler.
First, am I overlooking any way to accomplish this greater level of
restriction in current standard C++?
Second, would this actually be an improvement? I've never created a
programming language, so I could be overlooking important issues.
Finally, does a language already exist that has more strict restrictions
upon data and functions?