Which languages support *recursive* function literals / anonymous functions?

后端 未结 16 2350
一整个雨季
一整个雨季 2021-02-04 05:09

It seems quite a few mainstream languages support function literals these days. They are also called anonymous functions, but I don\'t care if they have a name. The important th

16条回答
  •  星月不相逢
    2021-02-04 06:07

    Delphi includes the anonymous functions with version 2009.

    Example from http://blogs.codegear.com/davidi/2008/07/23/38915/

    type
      // method reference
      TProc = reference to procedure(x: Integer);               
    
    procedure Call(const proc: TProc);
    begin
      proc(42);
    end;
    

    Use:

    var
      proc: TProc;
    begin
      // anonymous method
      proc := procedure(a: Integer)
      begin
        Writeln(a);
      end;               
    
      Call(proc);
      readln
    end.
    

提交回复
热议问题