From: Leo on
Hello,

I wonder if some lisp guru can help me write a function
define-obsolete-function-alias (similar to the one in emacs).

The minimal it should is:

(define-obsolete-function-alias old-name new-name)

and the compiler should issue a warning whenever old-name is used.

Thank you.

Leo
From: Helmut Eller on
* Leo [2010-07-02 08:53] writes:

> Hello,
>
> I wonder if some lisp guru can help me write a function
> define-obsolete-function-alias (similar to the one in emacs).
>
> The minimal it should is:
>
> (define-obsolete-function-alias old-name new-name)
>
> and the compiler should issue a warning whenever old-name is used.

(defmacro define-obsolete-function-alias (old new)
`(progn
(defun ,old (&rest args) (apply #',new args))
(define-compiler-macro ,old (&whole whole &rest args)
(declare (ignore args))
(warn "function ~s is obsolete; please use ~s" ',old ',new)
whole)))

Helmut
From: Leo on
On 2010-07-02 10:01 +0100, Helmut Eller wrote:
> (defmacro define-obsolete-function-alias (old new)
> `(progn
> (defun ,old (&rest args) (apply #',new args))
> (define-compiler-macro ,old (&whole whole &rest args)
> (declare (ignore args))
> (warn "function ~s is obsolete; please use ~s" ',old ',new)
> whole)))
>
> Helmut

Works like a charm. The 'warn' part was where I missed. Thank you.

BTW, what's the difference between define-compiler-macro and (setf
compiler-macro-function)?

Leo
From: Thomas A. Russ on
Leo <sdl.web(a)gmail.com> writes:

> BTW, what's the difference between define-compiler-macro and (setf
> compiler-macro-function)?

It's the same as the difference between defmacro and the
macro-expansion-function. One is a definition form, and the other is
the function, derived from the definition form, that takes the code (+
environment) and actually produces the macro-expanded code.

--
Thomas A. Russ, USC/Information Sciences Institute
From: Leo on
On 2010-07-02 19:46 +0100, Thomas A. Russ wrote:
> Leo <sdl.web(a)gmail.com> writes:
>
>> BTW, what's the difference between define-compiler-macro and (setf
>> compiler-macro-function)?
>
> It's the same as the difference between defmacro and the
> macro-expansion-function. One is a definition form, and the other is
> the function, derived from the definition form, that takes the code (+
> environment) and actually produces the macro-expanded code.

Thanks.

Leo