发现一个很有意思的模块,以后起名就可以起很长了,再也不怕起名重复,就是不知道又没有啥副作用

(define-namespace NAME [KEYWORD …] BODY)

Inside the namespace NAME, execute BODY. NAME can be any symbol (not quoted), but it’s highly recommended to use some form of separator (such as :, /, or -). For a complete description of this macro, please visit the frontpage with M-x names-view-manual.

In summary, this macro has two main effects:

  1. Any definitions inside BODY will have NAME prepended to the symbol given. Ex:

    (define-namespace foo- (defvar bar 1 “docs”) )

expands to

(defvar foo-bar 1 "docs")
  1. Any function calls and variable names get NAME prepended to them if such a variable or function exists. Ex:

    (define-namespace foo: (defun message (x y) nil) (message “%s” my-var) )

expands to

(defun foo:message (x y) nil)
(foo:message "%s" my-var)

Note how ‘message’ is expanded to ‘foo:message’ in the second form, because that function exists. Meanwhile, ‘bar’ is left untouched because ‘foo:bar’ is not a known variable name.

===============================

AUTOLOAD

In order for ‘define-namespace’ to work with “;;;###autoload” comments must replace all instances of “;;;###autoload” inside your ‘define-namespace’ with ‘:autoload’. Afterwards, add an “;;;###autoload” comment just above your ‘define-namespace’.

===============================

KEYWORDS

Immediately after NAME you may add keywords which customize the behaviour of ‘define-namespace’. For a list of possible keywords and a description of their effects, see the variable ‘names–keyword-list’.

模块名names

今天刚知道有letrec 所以这个包就没有什么优势了

letrec大概和这个包没什么关系,你是怎么用的?

起名很烦,let不能定义函数所以用这个模块 有letrec ,除非是全局变量,函数,其他都可以变成局部变量 全局的用define-namespace 阅读的时候很麻烦

(letrec ((f (lambda ()
              (message "Something"))))
  ;; Error!
  (f)
  ;; Correct
  (funcall f))

(require 'cl-lib)
(cl-flet ((f ()
            (message "Something")))
  (f))
;; => "Something"

letrec定义的函数也不能按普通函数定义的方法调用啊。

至于names,不是不能用,只是没必要。

遇到cl都是绕着走,没碰过不知到有这个

涨见识了 :rofl: