Limitations of let rec in OCaml

前端 未结 3 852
攒了一身酷
攒了一身酷 2021-02-19 22:10

I\'m studying OCaml these days and came across this:

OCaml has limits on what it can put on the righthand side of a let rec. Like this one

let memo_rec f         


        
3条回答
  •  佛祖请我去吃肉
    2021-02-19 22:52

    The kind of expressions that are allowed to be bound by let rec are described in section 7.3 of the manual. Specifically, function applications involving the let rec defined names are not allowed.

    A rough summary (taken from that very link):

    Informally, the class of accepted definitions consists of those definitions where the defined names occur only inside function bodies or as argument to a data constructor.

提交回复
热议问题