string vs String

Pedro Ferreira asa.sad at sadf.wa
Fri Dec 14 09:46:47 PST 2007


Bruce Adams Wrote:

> On Fri, 14 Dec 2007 07:18:43 -0000, Janice Caron <caron800 at googlemail.com>  
> wrote:
> 
> > On 12/14/07, davidl <davidl at 126.com> wrote:
> >>
> >> I noticed object.d alias string as invariant(char)[]
> >>
> >> But it's a bad choice of the name. string causes a lot name collision in
> >> my app.
> >
> > So ... change your app?
> >
> > Seriously, there's no way Walter could possibly have known what name
> > choices you had made in your app, unless you're suggesting that Walter
> > should be more clairvoyant.
> >
> >> And as a type. with first char capitalized is a much better choice!!
> >
> > And do you suppose that this would cause no name clashes at all with
> > anyone's apps? I imagine it would cause /more/. Anyone who's ever made
> > a string class has probably called it "String". To me, the lower case
> > s not only ensures fewer name clashes, but also makes it "feel" like a
> > primitive type (which it sort of almost is - I mean it's just an
> > array, not actually a class or a struct).
> 
> Actually if D had namespaces he wouldn't need to be clairvoyant. Everything
> would be safely tucked away in namespace std:: and only imported if the  
> programmer
> asked. IIRC the argument against them was simplicity but them to me to be  
> an
> essential grouping structure at the architecture level. Of course the need  
> for them
> can be delayed a fair while in the land of modules.

If you want namespaces, do

"static import" and you'll have to fully qualify the module identifier.
I'm not sure however if static "import object" works.

Anyway, if the OP wants to rename the standard "string" to "String" simply do something like "import object : string=String" or something similar.



More information about the Digitalmars-d mailing list