string initialization question.
Steven Schveighoffer
schveiguy at yahoo.com
Fri Jul 30 13:42:10 PDT 2010
On Fri, 30 Jul 2010 16:31:49 -0400, Jonathan M Davis
<jmdavisprog at gmail.com> wrote:
> On Friday, July 30, 2010 13:10:46 Steven Schveighoffer wrote:
>
>> It's not. The only runtime functions available to the compiler look
>> like
>> this:
>>
>> _d_newarrayT(TypeInfo ti, size_t length);
>
> I guess that's one thing that comes of not really implementing it as a
> primitive. If there are enough such functions that would be properly
> optimizable
> had they actually been implemented as primitives, I would think that
> there would
> be some merit in finding a way to get the compiler to understand that it
> can do
> such optimizations. But I really don't know how all that works in dmd,
> so I have
> no idea how feasible that is.
To be clear, the compiler could do the optimization if it had another
runtime function to call. But since there is *no* runtime function that
allocates a new array and initializes it with a custom initial element,
how do you make a primitive?
So if the function exists, the compiler can be fixed to make the sequence
of "create then assign" a primitive, but I think just a runtime function
is good enough, and will work without compiler changes.
-Steve
More information about the Digitalmars-d-learn
mailing list