digitalmars.D - Shouldn't have IsAlpha() from std.uni has a different name to avoid
- MacAsm (11/11) Aug 21 2014 I'm trying to write in D rather than C++ an application where I
- ketmar via Digitalmars-d (11/13) Aug 21 2014 they doing much the same, but for different character sets. two
- Uranuz (6/20) Aug 22 2014 It's useful advice. But the only problem that I experience from
- Jonathan M Davis via Digitalmars-d (12/20) Aug 21 2014 Exactly. They're doing the same thing but for different character sets, ...
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.
Aug 21 2014
On Thu, 21 Aug 2014 15:27:46 +0000 MacAsm via Digitalmars-d <digitalmars-d puremagic.com> wrote:Any thoughts? I don't know if I'm missing something but two=20 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! ;-)
Aug 21 2014
On Thursday, 21 August 2014 at 15:36:41 UTC, ketmar via Digitalmars-d wrote:On Thu, 21 Aug 2014 15:27:46 +0000 MacAsm via Digitalmars-d <digitalmars-d puremagic.com> wrote: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!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! ;-)
Aug 22 2014
On Thu, 21 Aug 2014 18:36:30 +0300 ketmar via Digitalmars-d <digitalmars-d puremagic.com> wrote:On Thu, 21 Aug 2014 15:27:46 +0000 MacAsm via Digitalmars-d <digitalmars-d puremagic.com> wrote: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 DavisAny 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.
Aug 21 2014