[fpc-devel] Delphi anonymous methods

Michael Van Canneyt michael at freepascal.org
Tue Mar 5 10:25:22 CET 2013



On Tue, 5 Mar 2013, Graeme Geldenhuys wrote:

> On 2013-03-04 20:33, Howard Page-Clark wrote:
>>
>> You can simulate this in FPC as well as TP by using a local typed
>> constant. e.g.
>>
>> function GetValue: integer;
>> const value: integer = 0;
>> begin
>>    Inc(value);
>>    Result:= value;
>> end;
>
>
> I've seen this before, and always been baffled by this. How can you
> increment a "constant"? If you can, it is then a variable, no?

A leftover from the TP days. 
A typed constant acts as an initialized variable.

You can disable this construct with:
http://www.freepascal.org/docs-html/prog/progsu42.html

Michael.



More information about the fpc-devel mailing list