Updated DIP22 - Private symbol visibility

Martin Nowak code at dawg.eu
Sat Dec 21 14:06:13 PST 2013


On 12/21/2013 10:22 PM, H. S. Teoh wrote:
> I was pretty upset when I encountered the following situation:
>
> 	---std/regex.d---
> 	...
> 	private struct Stack { ... }
> 	...
>
> 	---mymodule.d---
> 	...
> 	/* public */ struct Stack { ... }
> 	...
>
> 	---main.d---
> 	import std.regex;
> 	import mymodule;
>
> 	Stack s; // compile error: 'Stack' is ambiguous
>
> I find it unacceptable that introducing a *private* symbol to std.regex
> will break existing code (std.regex.Stack wasn't there in earlier
> versions of Phobos). Since std.regex.Stack is private, why would it even
> be in *any* overload set when compiling main.d??! This is leaky
> abstraction at its best: changing the implementation of a module without
> changing its API can randomly break user code due to newly-introduced
> private symbols clashing with user-defined symbols.
>
Yes, this is the big issue that we try to address with DIP22.
Happened to me too when I added a private `abs` helper to core.time
which then caused conflicts somewhere else in phobos.



More information about the Digitalmars-d mailing list