On 19 Oct 2009, at 16:18, Peter Popov wrote:
An example would be
TItemCache = class
private
const DEFAULT_CACHE_SIZE = 1024;
...
end;
sure a global value would do, but there is no need for the value to
be global.
This is a good example. However, the same paradigm can be achived by
a function:
function TItemCache.DEFAULT_CACHE_SIZE: Integer;
begin
Result := 1024;
end;
If properly inlined, the compiled code is the same and semantically
the two are the same.
Except if you want to use the constant in another constant expression
(which is not possible with a function, inlined or not).
Jonas
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel