Top 5

Sergey Gromov snake.scaly at gmail.com
Fri Oct 10 08:19:45 PDT 2008


Fri, 10 Oct 2008 19:10:19 +0400,
Denis Koroskin wrote:
> On Fri, 10 Oct 2008 18:33:43 +0400, Andrei Alexandrescu  
> <SeeWebsiteForEmail at erdani.org> wrote:
> 
> > Sergey Gromov wrote:
> >> I'd also like
> >>   "foo" ~ text ~ "bar"
> >> to become something like
> >>   (new Array!(char)) ~= "foo" ~= text ~= "bar"
> >> that is what Java does to string concatenation.  Sugar doesn't seem to  
> >> couple well with a purely library type.
> 
> I doubt that. Java strings are immutable, their length can't be changed  
> either (i.e. they are a direct analog of a proposed invariant(char)[]).
> Concatanating Java strings don't turn them into array, and it is dead  
> slow. Every sane person uses StringBuilder instead.

Java compiler substitutes

"foo" + text + "bar"

with

new StringBuilder().append("foo").append(text).append("bar").toString()

all by itself because both String and StringBuilder are built-in 
classes.



More information about the Digitalmars-d mailing list