static and protection

Don Clugston dac at nospam.com.au
Fri Mar 3 02:32:40 PST 2006


Hasan Aljudy wrote:
> David Medlock wrote:
>> Tony wrote:
>>
>> Disclaimer: the OP code seems to be a bug, I am not contradicting that.
>>
>> Each time I hear things like this I always ask for specific pragmatic 
>> examples of strict protection benefits outside of simple 
>> namespace-clash issues(which also mean IDE code completion).
>>
>> I've yet to see a good example in which strict protection attributes 
>> prevented any defects.  Thus far this is a sky-is-falling issue, with 
>> very little real practical evidence.
> 
> It's not obvious in small programs, but it becomes crucial in large 
> projects, and even more crucial in projects with millions of lines of code.
> 
> I think the dmd compiler is a good example.
> Don't you see how Walter spends more time fixing bugs than adding new 
> features?!

You're kidding, right? Generally, the features don't get descriptions as 
long as the bugs do. Some of those features are *huge*. Also, what tends 
to happen is that we get a staged implementation of features -- most of 
the bugs are extending the feature to apply in more situations.

> If you look at the source code you can understand why.
> I must say that I'm amazed how he can maintain the source code of the 
> compiler!!
> However, I think that if he'd used proper object oriented model for the 
> compiler, less bugs will need to be fixed, and maybe v1.0 would've been 
> ready along time ago!

?? Name another language that has progressed anywhere near as fast.

I think that pure OO has largely been a failure. It's failed to live up 
to its initial hype. (Specifically, the claim of code reuse has _not a 
scrap_ of truth to it. History has shown that the only time you get code 
reuse is when you intentionally design a library. C has a better history 
of code reuse than object-oriented C++!). What _is_ true is that 
cohesion leads to more reliable code.

On a tangentially related topic:
Something I'm finding very interesting about D is inner functions.
I'm finding that lots of things I would have used private class members 
for, I'm now using nested functions instead, with the result that simple 
classes sometimes disappear completely.

With nested functions, you get extremely strong cohesion -- better than 
is possible in OOP. eg, generally, private class functions aren't 
completely private in OO languages. They appear in vtables, for example.

I don't think this programming paradigm has been very well explored yet.




More information about the Digitalmars-d mailing list