Top 5
Steven Schveighoffer
schveiguy at yahoo.com
Fri Oct 10 09:35:41 PDT 2008
"Benji Smith" wrote
> Steven Schveighoffer wrote:
>> "Benji Smith" wrote
>>> I think *all* arrays should be declared like this:
>>>
>>> T[] array = new T[n];
>>>
>>> If "n" is known it compile time, then D can use CTFE to create a static
>>> array, and if "n" isn't known until runtime, it can create a dynamic
>>> array. But as the user, I don't want to care which is which.
>>
>> What if n is 10000? It's small enough that it could be stack allocated,
>> but large enough that you might not want it to do that.
>
> Sounds like a perfect decision for the compiler (or the runtime) to make.
>
> D eliminated the "register" and "inline" keywords for exactly the same
> reason.
How can the compiler quantify exactly how many times this function will be
called in the same stack? How will it know that this won't cause a stack
overflow?
The register keyword is easy, the compiler can't run out of register space
and cause an exception.
inline also won't cause unforseen runtime errors.
So I see this as a different issue.
-Steve
More information about the Digitalmars-d
mailing list