473,395 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Improvement to C++

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?
Jul 19 '05 #1
1 1830
"Russell Reagan" <rr*****@attbi.com> 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
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sree | last post by:
hello, I am working on a project that requires improving the performance of xml to reduce the access time . I use xml to take the values from a database located in US and store the values and...
40
by: Ron Adam | last post by:
After considering several alternatives and trying out a few ideas with a modified list object Bengt Richter posted, (Thank You), I think I've found a way to make slice operation (especially far end...
7
by: qvx | last post by:
Hi all, I have a performance problem in my app. It is a poor man's version of OCR app. I started this app as a prototype before implementing it in C++. But now, after I have a working copy in...
1
by: Peter Arrenbrecht Opus | last post by:
Hello IBM I think that one could improve the performance of DB2 UDB v7.2's stored procedure resolution. Here's what DB2 normally does: SELECT A.PROCSCHEMA, A.PROCNAME, A.PARMNAME,...
11
by: dba2adm | last post by:
I have a view which references two different tables at different times say t_1 on certain days and t_2 on certain other days. In oracle I have many many ways of doing this without having much...
10
by: Gary | last post by:
I would like to know if I use C# instead of Vb.Net for Server components, will there a performance improvement ? TIA, Gary
9
by: wdwedw | last post by:
I have included all the source codes in the attached MyTest.zip (http://www.codeguru.com/forum/attachment.php?attachmentid=11218) There are three projects: VBTestCOM project is a apartment...
4
by: Sam Durai | last post by:
Hello, I have a requirement to delete millions of rows from a table which has billions of rows. Hence I have coded a korn script to delete rows recursively and with a commit interval of 10000....
21
by: James Stroud | last post by:
I think that it would be handy for enumerate to behave as such: def enumerate(itrbl, start=0, step=1): i = start for it in itrbl: yield (i, it) i += step This allows much more flexibility...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.