Re: Poll: SizeOf(variable) vs SizeOf(type), should SizeOf(variable)be banned ?



Skybuck Flying wrote:
SizeOf(Buffer);

What if Buffer is changed from a static array to a dynamic array.

Putting the type name there instead wouldn't help any. The size of a dynamic array is always 4.

SizeOf doesn't work for dynamic arrays.

Another reason why not to use SizeOf like that.

One main reason I started to program in TurboPascal and later Delphi is that it's more easy to change code in Delphi without running into all kinds of stupid changes and/or bugs everywhere, sometimes some smartness is needed as well.

Using SizeOf on static buffers is clearly not very smart <- bug prone.

OK. So don't do that. Nothing to do with the issue at hand, though.

--
Rob
.



Relevant Pages