Shouldn't have IsAlpha() from std.uni has a different name to avoid confusing from std.ascii?
I'm trying to write in D rather than C++ an application where I do need to write a small parsing library. These two modules part of D standard library (no idea if it's D term to call a library/module part of the language itself) has the same name. Depeding if imported is either std.uni or std.ascii it does have exactly the opposite behavior. Not sure of it is only for me, but as part of the standard library I see this as a negative point and I think it would be better if one(the one from IsAlpha(), my suggestion) of is ranamed. Any thoughts? I don't know if I'm missing something but two functions (and not methods) with same name is very bad.
Re: Shouldn't have IsAlpha() from std.uni has a different name to avoid confusing from std.ascii?
On Thu, 21 Aug 2014 15:27:46 + MacAsm via Digitalmars-d wrote: > Any thoughts? I don't know if I'm missing something but two > functions (and not methods) with same name is very bad. they doing much the same, but for different character sets. two different names will just confuse users. you can use fully qualified names and/or local imports to use exactly what you want. something like: void myFunc (char ch) { import std.ascii; if (std.ascii.isAlpha(ch)) ... } local imports rocks! ;-) signature.asc Description: PGP signature
Re: Shouldn't have IsAlpha() from std.uni has a different name to avoid confusing from std.ascii?
On Thu, 21 Aug 2014 18:36:30 +0300 ketmar via Digitalmars-d wrote: > On Thu, 21 Aug 2014 15:27:46 + > MacAsm via Digitalmars-d wrote: > > > Any thoughts? I don't know if I'm missing something but two > > functions (and not methods) with same name is very bad. > they doing much the same, but for different character sets. two > different names will just confuse users. > > you can use fully qualified names and/or local imports to use exactly > what you want. Exactly. They're doing the same thing but for different character sets, so they have the same name. You then use the module system to distinguish them. So, the module system is doing its job. The alternative is to do something like prefix functions with the module name (e.g. isUniAlpha and isASCIIAlpha), in which case, we're ignoring the module system, and making the names unnecessarily long. The module system was designed to deal with conflicts like this. So, if two functions do different things, we give them different names, but if they're doing the same thing (as in this case), we give them the same name. - Jonathan M Davis
Re: Shouldn't have IsAlpha() from std.uni has a different name to avoid confusing from std.ascii?
On Thursday, 21 August 2014 at 15:36:41 UTC, ketmar via Digitalmars-d wrote: On Thu, 21 Aug 2014 15:27:46 + MacAsm via Digitalmars-d wrote: Any thoughts? I don't know if I'm missing something but two functions (and not methods) with same name is very bad. they doing much the same, but for different character sets. two different names will just confuse users. you can use fully qualified names and/or local imports to use exactly what you want. something like: void myFunc (char ch) { import std.ascii; if (std.ascii.isAlpha(ch)) ... } local imports rocks! ;-) It's useful advice. But the only problem that I experience from time to time that local imports become source of linker error that are not very easy to find. But language descision for this is good and I like it a lot!