Side effects in Scala

前端 未结 2 861
借酒劲吻你
借酒劲吻你 2021-01-04 01:29

I am learning Scala right in these days. I have a slight familiarity with Haskell, although I cannot claim to know it well.

Parenthetical remark for those wh

2条回答
  •  耶瑟儿~
    2021-01-04 02:00

    No, this is not possible in principle in Scala, as the language does not enforce referential transparency -- the language semantics are oblivious to side effects. Your compiler will not track and enforce freedom from side effects for you.

    You will be able to use the type system to tag some actions as being of IO type however, and with programmer discipline, get some of the compiler support, but without the compiler proof.

提交回复
热议问题