Sugestão para viabilizar o uso de procedure anônima no método Listen (com FPC)
edsontmarques opened this issue · 5 comments
edsontmarques commented
Similar ao que já se encontra na unit Horse.Callback, sugeriria avaliar a possibilidade de alterar a Horse.Proc da seguinte forma:
unit Horse.Proc;
{$IF DEFINED(FPC)}
{$MODE DELPHI}{$H+}
{$IF DEFINED(HORSE_FPC_FUNCTIONREFERENCES)}
{$MODESWITCH FUNCTIONREFERENCES+}
{$ENDIF}
{$ENDIF}
interface
{$IF NOT DEFINED(FPC)}
uses
System.SysUtils;
{$ENDIF}
type
TNextProc = {$IF DEFINED(FPC)}procedure of object{$ELSE}System.SysUtils.TProc{$ENDIF};
TProc = {$IF DEFINED(FPC)}{$IF DEFINED(HORSE_FPC_FUNCTIONREFERENCES)}reference to {$ENDIF}procedure{$ELSE}System.SysUtils.TProc{$ENDIF};
{$IF DEFINED(FPC)}
TProc<T> = {$IF DEFINED(HORSE_FPC_FUNCTIONREFERENCES)}reference to {$ENDIF}procedure(Arg1: T);
{$ENDIF}
implementation
end.
viniciussanchez commented
edsontmarques commented
Boa tarde!
A ideia seria viabilizar a seguinte situação:
program Teste;
{$IFDEF FPC}
{$MODE DELPHI}{$H+}
{$MODESWITCH ANONYMOUSFUNCTIONS+}
{$ENDIF}
interface
implementation
uses
SysUtils;
begin
...
THorse.Listen(9000,
procedure
begin
WriteLn(Format('Server active on port %d', [THorse.Port]));
end);
end;
end.
Com o que sugeri (que foi o que eu implementei aqui no meu checkout local do Horse (trunk)), eu consigo usar procedure anônima direto dentro do Listen, o que é possível com o FPC 3.2.2.
viniciussanchez commented
Assim, legal... manda um Pull request entao pra gente, o que acha? dai seu nome aparece como contribuidor tambem do projeto
edsontmarques commented
Seria uma honra!
Vou preparar aqui!
viniciussanchez commented
Vlw
