import concerns (C++ visib question)

Sean Kelly sean at f4.ca
Sat Jul 8 23:27:54 PDT 2006


Bruno Medeiros wrote:
> Sean Kelly wrote:
>> Walter Bright wrote:
>>> Derek Parnell wrote:
>>>> I'm sorry Walter but I don't give newt's fart about C++. If I wanted 
>>>> to code under the rules of C++, I'd use C++. You have changed 
>>>> (improved) many of the C++ rules in D, so why not get this one right 
>>>> too?
>>>
>>> I agree that D exists to fix broken rules in C++, but we need to 
>>> understand the rationale for why they are the way they are in C++, 
>>> else we run the risk of making a severe error. I don't recall why the 
>>> access rules are the way they are in C++, but I do know they weren't 
>>> don't that way for backwards compatibility.
>>
>> Please see my post here:
>>
>> http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/39072
>>
>> According to Daveed Vandevoorde:
>>
>>    The fact that private members are inaccessible but not invisible
>>    regularly surprises incidental programmers. Like macros, seemingly
>>    unrelated declarations interfere with subsequent code. Unfortunately,
>>    there are good reasons for this state of affair: Without it, private
>>    out-of-class member declarations become impractical to parse in the
>>    general case.
> 
> Well, that clearly states that private members should not be invisible 
> in C++, but I'm having trouble understanding why. He says "Without it, 
> private out-of-class member declarations become impractical to parse in 
> the general case." but I don't see how or why, anyone has an example or 
> clarification?

It seems he's implying that "truly invisible" privates would require two 
separate methods of symbol lookup: one for calling functions and another 
for defining them (if the definition occurs outside class scope where 
the function being defined should technically be invisible).  I still 
don't really see the technical hurdle there, but then I've never written 
a C++ compiler so perhaps it would turn out to be more difficult in 
practice than in theory.  Perhaps it was simply something perceived 
difficult at the time the decision was made?  In any case, I'm hoping 
Walter can find out more than I did here.


Sean



More information about the Digitalmars-d mailing list