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.

Alternative "defun"

3 posts · 1047 views

I am trying to write a macro which works the same as defun - with name as "def"... Can anybody help? I think you can't write a function for this since you need to evaluate the name of the function, eg,
(defmacro def (name parameters body) ?)
And the other problem is that there need to be multiple optional arguments and the body of the macro.
TIA
Don't take the FUN out of DEFUN !

Re: Alternative "defun"

Usually defun is defined something like this:
(defmacro def (name lambda-list &body body)
  (setf (symbol-function ',name)
        #'(lambda ,lambda-list ,@body)))