Editing programs “while they are running”? How?

后端 未结 8 2120
夕颜
夕颜 2021-02-13 06:19

This question is a corollary to: Editing programs “while they are running”? Why?

I\'m only recently being exposed to the world of Clojure and am fascinated by a few exam

8条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-13 06:59

    Some language implementations have that for a long time, especially many Lisp variants and Smalltalk.

    Lisp has identifiers as a data structure, called symbols. These symbols can be reassigned and they are looked up at runtime. This principle is called late binding. Symbols name functions and variables.

    Additionally Lisp implementations either have at runtime an interpreter or even a compiler. The interface are the functions EVALand COMPILE. Plus there is a function LOAD, which allows loading of source code and compiled code.

    Next a language like Common Lisp has an object system which allows changes to the class hierarchy, classes themselves, can add/update/remove methods and propagates these changes to already existing objects. So the object-oriented software and code can be updated itself. With the Meta-object Protocol one can even re-program the object system at runtime.

    It's also important that Lisp implementations then can garbage collect removed code. That way the running Lisp will not grow in runtime size just because code is replaced.

    Lisp often also has an error system which can recover from errors and allows replacing defective code from within the debugger.

提交回复
热议问题