string initialization question.

Justin Spahr-Summers Justin.SpahrSummers at gmail.com
Fri Jul 30 16:41:03 PDT 2010


On Fri, 30 Jul 2010 16:30:17 -0700, Jonathan M Davis 
<jmdavisprog at gmail.com> wrote:
> On Friday, July 30, 2010 14:13:15 dcoder wrote:
> > If I'm writing a program that pretty prints tree data, or output of sql,
> > like Oracle's sqlplus, or postgres equivalent, I find having such a
> > utility function/constructor a pretty handy feature.
> > 
> > I don't know where such a tool should finally be placed in D, but I having
> > it available as a library or as part of the language would be great.  It
> > seems like a lot of other languages have it like python, perl, C++, and
> > Java.  So it can't be that useless.
> 
> Well, I certainly have no problem with a function like makeArray() existing. 
> It's just that it's one of those functions that I've never found useful, and I 
> don't think that I've ever seen anyone use it in code.

I agree with this sentiment. I think the feature is pretty niche to 
begin with, and the compiler should be able to optimize out the 
initialization in the sample I gave previously. D is indeed a systems 
language, but I (and I'm sure others) would like to use it in a high-
level way, where I can write natural, straightforward code and expect 
the compiler to do the Right Thing.

Besides, performance is not an applicable argument for this use case. 
Even if the array initialization is compiled into the binary, the amount 
of time it would take is infinitesimal. If someone's trying to 
initialize a 100,000 element array to some specific value, they're 
likely going to write their own makeArray() anyways.


More information about the Digitalmars-d-learn mailing list