This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Define macro alias?

5 posts · 7137 views

I just switched my terminal to UTF-8 and got UTF-8 working in emacs and slime with SBCL. Now I want to write some funny lisp. I want λ to be interpreted as lambda, like an alias or something. I already figured out how to "alias" functions:
(setf (symbol-function 'add) #'+)
or
(setf (symbol-function 'add) (symbol-function '+))
I know that just redefines the function under a new name, but that's fine by me.

Now, I'd like to do the same thing for macros. Any ideas?

Re: Define macro alias?

Why not something like
(defmacro <name> ((&body lambda-list) &body body)
  `(lambda ,lambda-list ,@body))

Re: Define macro alias?

It sounds like you want to be able to write something like
(<-> 45 my-list)
where "<->" is some funky character, instead of
(push 45 my-list)
Is that correct? If so, you can just define another macro or transfer the macro function.
;; Wrapper macro which may provide nicer contextual help in something like SLIME
(defmacro <-> (value place) `(push ,value ,place))

;; Transfer the macro function, analogous to your previous work with symbol-function
(setf (macro-function '<->) (macro-function 'push))
In the latter case, you should make sure there is no symbol-function defined for the symbol. You can't have a symbol name both a symbol and a function.

Re: Define macro alias?

Perfect! Thank you Geoff.

I actually tried that last method, but I suppose I already setf'd that funky character to a function before, so I couldn't setf it to a macro.