Better to use “and” or “in” when chaining “let” statements?

前端 未结 4 1394
耶瑟儿~
耶瑟儿~ 2021-02-19 09:57

I realize this is probably a silly question, but...

If I\'m chaining a bunch of let statements which do not need to know each other\'s values, is it

4条回答
  •  鱼传尺愫
    2021-02-19 10:17

    It's the same as the difference between let and let* in Lisp, I believe. let* (similar in functionality to the in..in.. structure - the second structure in your question) is sometimes used to hide imperative programming since it guarantees sequential execution of expressions (see what Paul Graham had to say about let* in On Lisp).

    So, I'd say the former construct is better. But the truth is, I think the latter is more common in the Ocaml programs I have seen. Probably just easier to use in letting one build on previously named expressions.

提交回复
热议问题