[fpc-devel] Delphi anonymous methods
Howard Page-Clark
hdpc at talktalk.net
Mon Mar 4 21:33:59 CET 2013
On 04/03/13 6:34, waldo kitty wrote:
> i'm trying to understand what you mean by
>
> > Pascal don't allows to create static variables inside function like
> in c-like
> > languages.
>
> i've done something that i think is what you speak of but it was in
> Borland's Turbo Pascal... at least TP6... i don't remember how we did it
> though and can't find any sample code in my library :(
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;
Successive calls to GetValue() will return 1, 2, 3 etc.
More information about the fpc-devel
mailing list