Hi Rolf.
For most structures sizeof(...) returns a value of less than 256, so it would be nice if the following were allowed without error
provided, of course, that the result (which is, after all, a constant, albeit one calculated by the compiler) was less than 255.
One can, of course, use
but it is less elegant, and actually less safe, because if the structure happens to be more than 255 bytes the above is legal but wrong.
Also in structures like
rather than
which is quite ugly.
Obviously not an important or urgent refinement...
Regards
Merlin.
For most structures sizeof(...) returns a value of less than 256, so it would be nice if the following were allowed without error
Code
var
iLen : byte;
begin
iLen := sizeof( ...);
iLen : byte;
begin
iLen := sizeof( ...);
provided, of course, that the result (which is, after all, a constant, albeit one calculated by the compiler) was less than 255.
One can, of course, use
Code
var
iLen : byte;
begin
iLen := byte(sizeof( ...));
iLen : byte;
begin
iLen := byte(sizeof( ...));
but it is less elegant, and actually less safe, because if the structure happens to be more than 255 bytes the above is legal but wrong.
Also in structures like
Code
var
i : byte;
begin
for i := 0 to sizeof( ...) - 1 do
i : byte;
begin
for i := 0 to sizeof( ...) - 1 do
rather than
Code
var
i : byte;
begin
for i := 0 to byte(sizeof( ...)) - 1 do
i : byte;
begin
for i := 0 to byte(sizeof( ...)) - 1 do
which is quite ugly.
Obviously not an important or urgent refinement...
Regards
Merlin.