On Mon, Oct 19, 2009 at 9:18 AM, Peter Popov <ppopo...@gmail.com> 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. >> >> Martin > > 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. > Granted, defining it as constant saves the 4 lines needed to implement the > function :-) > > In the same example, a typed global constant gives it a different flavour, > in the sense that the user of the class can modify the value at run-time, > e.g. by reading an ini file/registry entries when the app starts. > > Peter > _______________________________________________ > fpc-devel maillist - fpc-de...@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-devel >
Well, if we're looking to add functionality I would think NameSpaces like in C# would be useful to bind constants and data structures to namespaces... Just my $0.02 _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel