Pathological import symbol shadowing

Paul Backus snarwin at gmail.com
Wed Nov 18 20:53:52 UTC 2020


On Wednesday, 18 November 2020 at 18:10:58 UTC, H. S. Teoh wrote:
> In this particular instance of problems caused by it, my 
> opinion is leaning towards std.curl.get being poorly-named. 
> HTTP GET is a rather narrow and specific function, as opposed 
> to object.get for AA's which are built into the language.  If 
> it weren't for that ever-looming spectre of breaking existing 
> code, I'd say rename it to something else. Like curlGet or 
> something.

std.curl.get is absolutely not at fault here. The whole point of 
modules (and namespaces in general) is that you can use whatever 
names you want in them without having to worry about conflicts. 
And if you need to use two different `get`s in the same scope, D 
has plenty of tools to help you disambiguate:

     import curl = std.curl;
     // ...
     curl.get(whatever);

     import std.curl;
     alias curlGet = std.curl.get;
     // ...
     curlGet(whatever);

     static import std.curl;
     // ...
     std.curl.get(whatever);


More information about the Digitalmars-d mailing list