www.digitalmars.com         C & C++   DMDScript  

D - My 2 cents

reply Kurt Blackwell <kurt blackwell.id.au> writes:
I'm glad someone is finally trying to fix all the shortcomings of C++, but I
have a couple of niggling concerns.

If you had something like:

class Thingy
{
void addass(int i); /* For the sake of a quick example, I didn't bother checking
what this should return :) */
};

void foo(Thingy t)
{
t += 1;
}

And you decided that 'Thingy' should now be

typedef int Thingy;

Then foo() will no longer have any effect, and I'll have to search my code for
any other occurrences like this and change it to 'inout Thingy'.  It seems quite
reasonable that an object that has += overloaded, could be replaced with an
integral type and += can be used with no additional side effects.

Please correct me if I'm wrong, but this must violate at least one programming
principle about consistency somewhere.


My other thing is that it's a pitty that all you're improvements on C++ is
wasted when it comes to real-time applications due to garbage collection.  But,
if you're mind is made up, then there's not much I can say to change that :)
Jan 12 2003
parent "Walter" <walter digitalmars.com> writes:
I think in general what you're seeing is the difference between a reference
and a value type. You can work around this by using a struct instead of a
class.

Also, the gc won't run unless you actually call it. So, if you have a real
time section of code, preallocate what you need beforehand, or just use
malloc().

-Walter

"Kurt Blackwell" <kurt blackwell.id.au> wrote in message
news:avs4ba$2mv6$1 digitaldaemon.com...
 I'm glad someone is finally trying to fix all the shortcomings of C++, but

 have a couple of niggling concerns.

 If you had something like:

 class Thingy
 {
 void addass(int i); /* For the sake of a quick example, I didn't bother

 what this should return :) */
 };

 void foo(Thingy t)
 {
 t += 1;
 }

 And you decided that 'Thingy' should now be

 typedef int Thingy;

 Then foo() will no longer have any effect, and I'll have to search my code

 any other occurrences like this and change it to 'inout Thingy'.  It seems

 reasonable that an object that has += overloaded, could be replaced with

 integral type and += can be used with no additional side effects.

 Please correct me if I'm wrong, but this must violate at least one

 principle about consistency somewhere.


 My other thing is that it's a pitty that all you're improvements on C++ is
 wasted when it comes to real-time applications due to garbage collection.

 if you're mind is made up, then there's not much I can say to change that


Jan 12 2003