Problem with coupling shared object symbol visibility with protection

Benjamin Thaut via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 28 06:16:02 PST 2015


On Wednesday, 28 January 2015 at 13:48:45 UTC, Dicebot wrote:
>
> Isn't that what your first proposed solution is about? That was 
> my understanding and I liked that understanding :) To be 100% 
> clear :
>
> export void foo(T : int)(T x)
> {
>     bar(x);
> }
>
> private void bar(int x) { }
>
> I'd expect `bar` to be exported into resulting binary so that 
> it can be linked against by any users of `foo` but for any 
> attempt to call `bar` directly from D code to fail because of 
> protection violation. If someone wants to circumvent protection 
> by forging mangling - shooting own feet is allowed.

Well this would be ultimate goal. Although it is not possible to 
automatically detect that bar needs to be exported because that 
would mean you would have to analyze all possible instantiations 
of the template foo. (static if...)
So Automatically detecting that bar needs to be exported is not 
possible. We either have to make export into an attribute or use 
the solution where bar is actually nested into a struct which is 
exported instead. This is also described in my initial post with 
examples.


More information about the Digitalmars-d mailing list