Optimization question

Hey guys :slight_smile:

what do you think about the chance to place an dynamic array, which get its length at runtime, to place it instead to the heap, to the stack, because you actually know the size, at the moment, when “length” is known.

Would that be possible?

Best regards

For example:

constructor(length: int); 
begin
  dyn_arr := new array of Byte(length);  //could this still be placed at the stack?
end;

Shpend

Furthermore, I am really wondering, if this couldnt work fine: (at the mom, compiler error)

constructor (const min, max: LongInt; const input: array[0..(max-min)] of ValueType);    
begin
   //because, at the mom when the compiler knows "min" and "max", he could actually 
   //place the "input" to the stack, he does then know the range and the type to create the
   //array, doesnt he?
end;

That can’t work no. You can’t have a method sig like that.

hmm, do you mean this signature wouldnt work:?

constructor (const min, max: LongInt; const input: array[0..(max-min)] of ValueType);

And what do you say about the first question, to place the dynamic-array to the stack instead on the heap?

Actually, something in me say, this should work somehow :shushing_face::shushing_face: