Difference between “local” and “let” in SML

后端 未结 2 1832
庸人自扰
庸人自扰 2020-12-06 11:31

I couldn\'t find a beginner friendly answer to what the difference between the \"local\" and \"let\" keywords in SML is. Could someone provide a simple example please and ex

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 12:29

    The short answer is: local is a declaration, let is an expression. Consequently, they are used in different syntactic contexts, and local requires declarations between in and end, while let requires an expression there. It's not much deeper than that.

    As @SimonShine mentioned, local is often discouraged in favour of using modules.

提交回复
热议问题