Is it possible to have an alias for the function name in Lisp?

后端 未结 8 1401
梦毁少年i
梦毁少年i 2021-02-05 20:37

...just like packages do.

I use Emacs (maybe, it can offer some kind of solution).

For example (defun the-very-very-long-but-good-name () ...) is no

相关标签:
8条回答
  • 2021-02-05 21:08

    You could simply have a function that just calls another function.

    0 讨论(0)
  • 2021-02-05 21:09

    you can use (defmacro ...) to alias a function

    0 讨论(0)
  • 2021-02-05 21:13

    If your problem is that you can't remember a very long function name, but you remember PART of the name, that's what "apropos" is for. In my Emacs, I have "C-h a" bound to "hyper-apropos". You enter a substring of the symbol you're looking for, and it lists all the matches.

    0 讨论(0)
  • 2021-02-05 21:14

    I dont know Emacs, but wouldn't (define shortname longnamefunctionblahblah) work?

    0 讨论(0)
  • 2021-02-05 21:15

    You could use setf to assign the function to the function cell of another, for example:

    (defmacro alias (new-name prev-name)
      `(setf (symbol-function ,new-name) (symbol-function ,prev-name))) 
    
    0 讨论(0)
  • 2021-02-05 21:22

    You want defalias. (defalias 'newname 'oldname) will preserve documentation and even show "newname is an alias for `oldname'" when its documentation is requested.

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