Why is the raising of an exception a side effect?

前端 未结 5 1896
清歌不尽
清歌不尽 2020-12-13 05:50

According to the wikipedia entry for side effect, raising an exception constitutes a side effect. Consider this simple python function:

def foo(arg):
    if          


        
5条回答
  •  不思量自难忘°
    2020-12-13 06:29

    Referential transparency is also the possibility to replace a computation (e.g. a function invocation) with the result of the computation itself, something that you can't do if your function raises an exception. That's because exceptions do not take part of computation but they need to be catch!

提交回复
热议问题