Why can't functions and struct types have the same name?

Joakim via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 26 03:50:21 PST 2015


On Monday, 26 January 2015 at 11:30:00 UTC, Daniel Kozak wrote:
> On Monday, 26 January 2015 at 11:15:26 UTC, Joakim wrote:
>> Right now, I had to go through and selectively import all 14 
>> symbols I needed from the 3 druntime modules that publicly 
>> import core.sys.posix.sys.socket, so that the function socket 
>> isn't imported.  Seems like a pain that can be mitigated by a 
>> smarter compiler.
>
> You can use static import, or alias to solve this issue

Yep, both seem to be an easier way to fix the compile error.  
With the static import, it seemed painful to add the fully scoped 
path to every symbol from the third-party C library, but I forgot 
that you can simply use the fully scoped path when invoking the 
struct type alone, when it's not a static import, so that works.  
As for an alias, I didn't think of that, but that also requires 
the fully scoped path that I had forgotten about.


More information about the Digitalmars-d-learn mailing list