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



Skybuck Flying wrote:
Some programmers write (in my oppinion) sloppy code such as:

var
i : integer;
begin
I := SizeOf(I);
end;

This should be:

var
i : integer;
begin
I := SizeOf(Integer);
end;

Why "should" it be that?

I rather prefer the former style. If the variable is supposed to hold its size, and I change the type of that variable, one style requires me to also change code elsewhere in the program, whereas the other style is automatically correct. The latter style also requires me to remember what the type of the variable is. The declaration of the relevant variable isn't always just two lines above the assignment.

Now, if you were also proposing a TypeOf function, such that the following code would be legal, I might be convinced.

I := SizeOf(TypeOf(I));

Poll question:

Should SizeOf(variable) be banned by Borland in their next compiler/IDE release ?

Borland doesn't release compilers anymore.

--
Rob
.



Relevant Pages