Error handling in Swift does not involve stack unwinding. What does it mean?

前端 未结 2 1637
执念已碎
执念已碎 2021-01-13 10:27

According to the docs,

error handling in Swift does not involve unwinding the call stack, a process that can be computationally expensive

2条回答
  •  孤街浪徒
    2021-01-13 10:51

    It's true that if swift stack unwinds then it will call all the destructor of all the objects that were allocated since the beginning of the block. But the converse might not be true. Just because the destructor was called for your object A does not imply that swift stack unwinds. Also if you really wanted to test if it is stack unwinding you should try a more rigorous example

提交回复
热议问题