对于 C/C++,人们使用#ifdef .. #endif 技术来防止重新加载库,而 Objective-C 使用 import 来做同样的事情。
lisp/elisp 怎么样?如果之前使用了 (require 'cl),并且在某处看到了 (require 'cl),lisp 是否足够聪明,不会再次加载它?或者,有什么方法可以防止重新加载库?
最佳答案
不,elisp 不会再次加载它。来自文档(C-h f require
):
"If feature FEATURE is not loaded, load it from FILENAME."
Common Lisp也是如此:
"The require function tests whether a module is already present (using a case-sensitive comparison); if the module is not present, require proceeds to load the appropriate file or set of files."
关于lisp - elisp/lisp 中的 'require' 是否会阻止重新加载库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3571457/