[frustration, sorry] Import conflict madness.

Derek Parnell derek at psych.ward
Sat Jun 17 16:20:19 PDT 2006


On Sun, 18 Jun 2006 04:30:32 +1000, Sean Kelly <sean at f4.ca> wrote:

> Derek Parnell wrote:
>>  I have yet to find a *need* for public imports.
>
> I have.  Implementing C headers it's common for an alias to be declared  
> in one header that must be visible in other headers.  Sure, you could  
> require the user to manually import both headers, but that's  
> non-intuitive and a tad annoying.  And the alternative (private import  
> combined with aliasing symbols to expose them piecemeal) results in  
> symbol collision problems.

And yet I find it intuitive and helpful. People differ.

For me, if 'foo' is declared in A, and B needs to access 'foo' then B  
should import A. Now if C needs to access something in B and access 'foo'  
it should import both A and B. This seems natural to me. To do otherwise  
means that C's access to 'A.foo' becomes dependant on the implementation  
of B. This is too much cohesion in my books.

And yes, it can result in the need to disambiguate public symbol  
references in C, but I see that as a good thing. It help document the code  
and reduces the chance of calling the wrong function.

-- 
Derek Parnell
Melbourne, Australia



More information about the Digitalmars-d mailing list