delphi - Can anything bad happen, if I clear my array by assigning a non-initialized array to it in pascal? -
in pascal, way dared cleaning array iterate through , clear it, extremely inefficient. can't reinitialize assigning empty array it?
program arrays; var working, empty : array [1..10] of integer; begin working[3] := 5; working:= empty; end.
is ok this, can backfire?
this absolutely fine. semantics of code need. delphi compiler emit code perform simple , efficient memory copy. compiler able because have fixed length array elements simple value types. i'd surprised if fpc did not produce similar code.
even if array contained managed types (it doesn't), assignment operator result in code respected managed types.
as final comment, array full of zeros should constant.
Comments
Post a Comment