[fpc-pascal] Use a procedural type for declare a procedure\function
Andrey M, Zubarev
zamtmn at gmail.com
Wed Apr 19 15:48:43 CEST 2017
Hi All,
Why can't use procedural type for declare a procedure\function?
Why ever allow the exact same signature? It's uncomfortable
Maybe it makes sense to introduce into the language such a possibility?
For example such code:
[code]
type TMyCommand=function(arg1:TMyArg):TMyCommandResult
begin
...
end;
function command1(arg1:TMyArg):TMyCommandResult;
begin
...
end;
function command2(arg1:TMyArg):TMyCommandResult;
begin
...
end;
function command100500(arg1:TMyArg):TMyCommandResult;
begin
...
end;
var
...
com:TMyCommand;
...
com:=GetNeededCommand;
res:=com(arg1:TMyArg)
[/code]
Could look like this
[code]
type TMyCommand=function(arg1:TMyArg):TMyCommandResult
begin
...
end;
command1 TMyCommand;
begin
...
end;
command2 TMyCommand;
begin
...
end;
command100500 TMyCommand;
begin
...
end;
...
var
com:TMyCommand;
..
com:=GetNeededCommand;
res:=com(arg1:TMyArg)
[/code]
--
Best regards,
Zubarev mailto:zamtmn at gmail.com
More information about the fpc-pascal
mailing list