[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Redefining functions and variables
From: |
Elena |
Subject: |
Re: Redefining functions and variables |
Date: |
Wed, 08 Dec 2010 15:21:24 -0000 |
User-agent: |
G2/1.0 |
On 27 Lug, 22:21, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> > I wonder whether there is a way to catch such redefinitions whenever
> > they happen (which also would help when accidentally redefining
> > something)
>
> Not sure what you mean by that.
Let's assume we have two definitions for the same function:
;; File A (loaded first)
(defun foo ()
...
;; File B (loaded later)
(defun foo () ;; This is a redefinition: I'd like to get a warning.
...
Since redefining functions is the heart of interactive programming,
such a warning should be issued only while loading files. That way,
you could consider whether to rename the second function or to rewrite
it as an advice (as you suggested).
If such a goal can only be achieved by rewriting "defun" and checking
by means of "fboundp" whether the function has already been defined,
here is my (failed, as noted) attempt:
(defmacro defun (name args &rest body)
`(progn
;; `load-file-name' is not null only if we are loading a file.
(when (and load-file-name
;; FAIL: I don't know how to quote the value of `name'.
(fboundp ,name))
(message "Warning: %s is being redefined in %s."
;; FAIL: I don't know how to quote the value of `name'.
(symbol-name ,name)
load-file-name)
(defun ,name ,args
,@body))))
Any suggestions? Thanks.
- Redefining functions and variables, Elena, 2010/12/08
- Re: Redefining functions and variables, Stefan Monnier, 2010/12/08
- Re: Redefining functions and variables,
Elena <=
- Re: Redefining functions and variables, Andreas Politz, 2010/12/08
- Re: Redefining functions and variables, Elena, 2010/12/08
- Re: Redefining functions and variables, Elena, 2010/12/08
- Re: Redefining functions and variables, Andreas Politz, 2010/12/08
- Re: Redefining functions and variables, Pascal J. Bourguignon, 2010/12/08
- Re: Redefining functions and variables, Elena, 2010/12/08
- Re: Redefining functions and variables, Stefan Monnier, 2010/12/08
- Re: Redefining functions and variables, Elena, 2010/12/08
- Re: Redefining functions and variables, Stefan Monnier, 2010/12/08
- Re: Redefining functions and variables, Uday S Reddy, 2010/12/08