Improvement to C++

Discussion in 'C++' started by Russell Reagan, Jul 2, 2003.

  1. 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?
    Russell Reagan, Jul 2, 2003
    #1
    1. Advertising

  2. "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
    Victor Bazarov, Jul 2, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JV
    Replies:
    4
    Views:
    1,619
  2. =?Utf-8?B?TWFyYyBIb2Vpam1hbnM=?=

    Performance improvement in the 2.0 framework

    =?Utf-8?B?TWFyYyBIb2Vpam1hbnM=?=, Mar 22, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    413
    Alvin Bruney - ASP.NET MVP
    Mar 22, 2006
  3. MaxMustermann

    Improvement on website

    MaxMustermann, Jul 23, 2005, in forum: HTML
    Replies:
    9
    Views:
    373
    MaxMustermann
    Jul 25, 2005
  4. sree
    Replies:
    2
    Views:
    439
    Edward A. Feustel
    Apr 17, 2005
  5. Duncan Booth

    generators improvement

    Duncan Booth, Aug 19, 2003, in forum: Python
    Replies:
    4
    Views:
    285
    Oleg Leschov
    Aug 20, 2003
Loading...

Share This Page