std.compress

Jonathan M Davis jmdavisProg at gmx.com
Sun Jun 9 18:59:14 PDT 2013


On Monday, June 10, 2013 11:44:56 Daniel Murphy wrote:
> In this case we can prevent problem simply by not giving functions generic
> names like 'compress'.  Ideally you should be able to import the entire
> standard library with no name conflicts.

We've actually made the opposite choice when discussing this in the past. 
We've specifically gone for making functions which do the same thing in 
different modules having the same name (e.g. std.ascii and std.uni), which 
makes swapping one for the other easy and avoids having to come up with 
distinct names, though it does obviously create more naming conflicts when you 
try and mix and match such modules. I'd also point out that it's been argued 
that it's a failure of the module system if we're specifically trying to avoid 
having different modules have functions with the same name. It's the module 
system's job to differentiate such functions, and specifically avoiding naming 
stuff the same to avoid naming conflicts means that you're pretty much ignoring 
the module system.

So, the general approach has been to name functions differently when they do 
different things and name them the same when they do the same thing and then 
let the module system take care of differentiating between the two when you 
need to.

- Jonathan M Davis


More information about the Digitalmars-d mailing list