Where did variable = null as “object destroying” come from?

后端 未结 14 1834
无人共我
无人共我 2021-02-18 15:51

Working on a number of legacy systems written in various versions of .NET, across many different companies, I keep finding examples of the following pattern:

pub         


        
相关标签:
14条回答
  • 2021-02-18 16:44

    It is more common in languages with deterministic garbage collection and without RAII, such as the old Visual Basic, but even there it's unnecessary and there it was often necessary to break cyclic references. So possibly it really stems from bad C++ programmers who use dumb pointers all over the place. In C++, it makes sense to set dumb pointers to 0 after deleting them to prevent double deletion.

    0 讨论(0)
  • 2021-02-18 16:47

    I've seen this a lot in VBScript code (classic ASP) and I think it comes from there.

    0 讨论(0)
提交回复
热议问题