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

后端 未结 16 2103
一整个雨季
一整个雨季 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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 05:53

    Well, apart from Common Lisp (labels) and Scheme (letrec) which you've already mentioned, JavaScript also allows you to name an anonymous function:

    var foo = {"bar": function baz() {return baz() + 1;}};
    

    which can be handier than using callee. (This is different from function in top-level; the latter would cause the name to appear in global scope too, whereas in the former case, the name appears only in the scope of the function itself.)

提交回复
热议问题