主动修改

主动修改计算机编程中,在一项的值变化时,其依赖项的值随之变化的行为模式。与惰性求值(Lazy Evaluation,又译为惰性计算、懒惰求值)相对。

假设数据项A的值依赖于数据项B的值。即B的值发生变化将导致A的值的变化。主动修改是在B变化后立即修改A。被动修改或称惰性求值是在取A的值时才修改A。一个具体例子是对于GUI应用程序,子菜单项的内容列表依赖于程序的状态,可以在程序状态改变时立即修改子菜单的列表(主动修改),也可以在仅当菜单被调用时才修改(被动修改)。[1]

另一个例子是:可以在底层数据改变时立即修改视觉显示,也可以仅在点击"redraw"按钮后修改。[2]

事务处理中的直接修改与延迟修改也是这种例子。[3]

参考文献

  1. Active Scripting Newsletter - Issue #58 - November 2004 页面存档备份,存于, Dr. Dobb's
  2. in: Human Aspects of Visualization: Second IFIP WG 13.7 Workshop on Human-Computer Interaction and Visualization, HCIV (INTERACT) 2009, Uppsala, Sweden, August 24, 2009, p. 49 页面存档备份,存于
  3. C++ Move Semantics for Exception Safety and Optimization in Software Transactional Memory Libraries 页面存档备份,存于, In book: Proceedings of the Third International Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems (ICOOOLPS), 2008
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.