I’ve noticed that different codes declare parameters in a different way to how I do, and I wonder if there is a specific reason to do so, or whether it is a preference.
Say I wrote this function (just an example with different parameters)
function DoSomething(AHeight, AWidth: Integer; R: TRect): Boolean
begin
//
end;
How is this any different then if it was declared like so:
function DoSomething(var AHeight, AWidth: Integer; const R: TRect): Boolean
begin
//
end;
I know a variable is read/writeable and a constant is read-only, but how does declaring parameters this way make a difference?
To me both functions are looking for the calling code to provide a Height, Width and Rect, but the 2nd function makes it look like we are declaring new variables.
I have a feeling this is going to be such a straight forward answer I feel silly for asking but I must know what the difference is, if any?
The documentation explains this very clearly:
I recommend that you add a link to the Delphi Language guide to your browser’s bookmarks.