Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Improvement to C++

Reply
Thread Tools

Improvement to C++

 
 
Russell Reagan
Guest
Posts: n/a
 
      07-02-2003
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?


 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-02-2003
"Russell Reagan" <> wrote...
> 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?


Whom do you ask?

> 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.


Permissions in file systems are run-time features. Access specifiers
in C++ are compile-time features. I am not sure how you manage to
compare them. There are, basically, no classes or members thereof,
during run-time. Hence, there is no need for any permissions.

> 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.


Not necessarily. There is a technique where you give access to some
third class from both A and B, which eliminates the necessity to open
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.


OTOH, it would make the system much more complex and much more difficult
to comprehend and maintain.

> First, am I overlooking any way to accomplish this greater level of
> restriction in current standard C++?


Yes, I think so. What you seem to be forgetting is 'const'. Make
a certain variable 'const' and you won't let others to change it.
Kind of "read-only".

> Second, would this actually be an improvement? I've never created a
> programming language, so I could be overlooking important issues.


I am not sure how "execute" would be an improvement. What problem would
it solve that cannot be solved today? As soon as you can demonstrate
that, you can show that it would be an improvement.

> Finally, does a language already exist that has more strict restrictions
> upon data and functions?


If it does, this is not the right place to ask about it. Try
comp.programming.

Victor


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Performance improvement in the 2.0 framework =?Utf-8?B?TWFyYyBIb2Vpam1hbnM=?= ASP .Net 6 03-22-2006 07:48 PM
Improvement on website MaxMustermann HTML 9 07-25-2005 04:43 AM
XML performance improvement sree XML 2 04-17-2005 08:28 PM
IMHO: DataBinding for ASP.NET list controls needs improvement (VS.NET 2003) JV ASP .Net 4 03-18-2005 06:40 PM
Collections Improvement Disillusioned_01 MCSD 1 06-08-2004 03:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57