Re: Poll: SizeOf(variable) vs SizeOf(type), should SizeOf(variable) be banned ?
- From: Rob Kennedy <me3@xxxxxxxxxxx>
- Date: Fri, 04 Jan 2008 18:42:44 -0600
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
.
- Follow-Ups:
- Re: Poll: SizeOf(variable) vs SizeOf(type), should SizeOf(variable)be banned ?
- From: Rudy Velthuis
- Re: Poll: SizeOf(variable) vs SizeOf(type), should SizeOf(variable)be banned ?
- References:
- Poll: SizeOf(variable) vs SizeOf(type), should SizeOf(variable) be banned ?
- From: Skybuck Flying
- Poll: SizeOf(variable) vs SizeOf(type), should SizeOf(variable) be banned ?
- Prev by Date: Re: What is the best way to do this in Delphi?
- Next by Date: Re: Destructor in delphi dll - noob question
- Previous by thread: Re: Poll: SizeOf(variable) vs SizeOf(type), should SizeOf(variable) be banned ?
- Next by thread: Re: Poll: SizeOf(variable) vs SizeOf(type), should SizeOf(variable)be banned ?
- Index(es):
Relevant Pages
|