Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Redefining a Common Lisp function

337 views
Skip to first unread message

Yuan-chi Chiu

unread,
May 17, 1994, 8:22:32 PM5/17/94
to
Hello comp.lang.list,

I'm using a utility file that contain alot of utility functions,
auxfns.lisp, where some of the Common Lisp functions are redefined using
'defun'. There is this one function called "Reduce" which gives me
a debugger prompt, telling me that I'm redefining a Common Lisp function
and ask me to type "continue" to accept this action. To solve the problem
would be just type in the "continue" as it asked and it'll finish loading
successfully.

Now I need to find a way to load that same file without it asking me
each time. Is there a special declaration or command that'll let me
do that? Please! I don't want to type "continue" again!

Thanks millions!

--
+-------------------------------------------------------------------------+
| Yuan-chi (Bill) Chiu. yc...@ucssun1.sdsu.edu. Amiga Enthusiast. |
|-------------------------------------------------------------------------|
| A process cannot be understood by stopping it. Understanding must move |
| with the flow of the process, must join it and flow with it. |
+-------------------------------------------------------------------------+

Len Charest

unread,
May 18, 1994, 5:00:06 PM5/18/94
to
In article <2rbn48$3...@gondor.sdsu.edu>,
Yuan-chi Chiu <yc...@ucssun1.sdsu.edu> wrote:
> ...I'm redefining a Common Lisp function
>and [the debugger] ask me to type "continue" to accept this action.
> Now I need to find a way to load that same file without it asking me
>each time. Is there a special declaration or command that'll let me
>do that? Please! I don't want to type "continue" again!

There is no portable way to disable such redefinition warnings/errors.
In fact, this kind of redefinition breaks portability of the entire
program. (See CLtL2, p 260.) The best solution would be to rename the
offending function or put it in a user-defined package.

However, the Lisp implementation you're using probably has a global
variable or function which controls what to do when redefining
built-in functions. For example, in Allegro CL 4.2, redefining a
built-in function causes a PACKAGE-LOCKED-ERROR. To get around the
error you could either unlock the package or write the appropriate
error handler. In any case, your workaround will depend on the Lisp
implementation you are using.

--
Len Charest, Jr.
JPL Artificial Intelligence Group
cha...@underdog.jpl.nasa.gov

"There's no need to fear...Underdog is here!"

Jeff Berger

unread,
May 18, 1994, 3:48:20 PM5/18/94
to
In article <2rbn48$3...@gondor.sdsu.edu> yc...@ucssun1.sdsu.edu (Yuan-chi Chiu) writes:

Hello comp.lang.list,

I'm using a utility file that contain alot of utility functions,
auxfns.lisp, where some of the Common Lisp functions are redefined using
'defun'. There is this one function called "Reduce" which gives me
a debugger prompt, telling me that I'm redefining a Common Lisp function
and ask me to type "continue" to accept this action. To solve the problem
would be just type in the "continue" as it asked and it'll finish loading
successfully.

Now I need to find a way to load that same file without it asking me
each time. Is there a special declaration or command that'll let me
do that? Please! I don't want to type "continue" again!

Rename your function in auxfns.lisp. You do not want to change the
function definition of a standard CL function. Doing so is guaranteed
to give you future headaches.

-JB
--
Jeff Berger |USmail: Ryerson 256
ber...@cs.uchicago.edu | Artificial Intelligence Lab
PH: (312) 702-8584 | 1100 East 58th Street
FX: (312) 702-8487 | Chicago, IL 60637

Marty Hall

unread,
May 19, 1994, 10:18:50 AM5/19/94
to
cha...@underdog.jpl.nasa.gov (Len Charest) writes:
>Yuan-chi Chiu <yc...@ucssun1.sdsu.edu> wrote:
>> ...I'm redefining a Common Lisp function
>>and [the debugger] ask me to type "continue" to accept this action.
>> Now I need to find a way to load that same file without it asking me
>>each time. Is there a special declaration or command that'll let me
>>do that? Please! I don't want to type "continue" again!
>
>There is no portable way to disable such redefinition warnings/errors.

I was under the impression that doing SETF on the SYMBOL-FUNCTION bypassed
any warnings. No?

In Mr. Chiu's case, he almost certainly didn't want to redefine the built-in
function, but either give it a different name or put it in a separate
package. But there *are* times when you want to redefine built-in functions.
For instance, I have a minor metering hack called WITH-FUNCTION-CALL-COUNT
that will run a body of code, counting how many times the specified functions
are called in the process. It replaces the function definitions by a simple
closure that increments a counter and then calls the original function. The
user should be able to specify built-in functions (assuming they aren't
inlined), and wouldn't want warnings. A similar example is Jeff Siskend's
Screamer package, which adds Prolog-like non-determinism to Lisp, but needs to
modify some built-in things to add additional bookkeeping.

- Marty

chyde

unread,
May 20, 1994, 4:20:59 PM5/20/94
to
In article <BERGER.94M...@pride.cs.uchicago.edu> ber...@cs.uchicago.edu (Jeff Berger) writes:
--> In article <2rbn48$3...@gondor.sdsu.edu> yc...@ucssun1.sdsu.edu (Yuan-chi Chiu) writes:
-->
--> Hello comp.lang.list,
-->
--> I'm using a utility file that contain alot of utility functions,
--> auxfns.lisp, where some of the Common Lisp functions are redefined using
--> 'defun'. There is this one function called "Reduce" which gives me
--> a debugger prompt, telling me that I'm redefining a Common Lisp function
--> and ask me to type "continue" to accept this action. To solve the problem
--> would be just type in the "continue" as it asked and it'll finish loading
--> successfully.
-->
--> Now I need to find a way to load that same file without it asking me
--> each time. Is there a special declaration or command that'll let me
--> do that? Please! I don't want to type "continue" again!
-->
--> Rename your function in auxfns.lisp. You do not want to change the
--> function definition of a standard CL function. Doing so is guaranteed
--> to give you future headaches.

all this advice is worthy, but suppose all you have is a .FASL ? then
what? you HAVE TO accept the redefinition, which means something like
the Allegro PACKAGE-LOCKED attribute.

-- clint

Espen J. Vestre

unread,
May 24, 1994, 6:07:44 AM5/24/94
to
In article <BERGER.94M...@pride.cs.uchicago.edu> Jeff Berger,

ber...@cs.uchicago.edu writes:
> In article <2rbn48$3...@gondor.sdsu.edu> yc...@ucssun1.sdsu.edu
(Yuan-chi Chiu) writes:
>
> Hello comp.lang.list,
>
> I'm using a utility file that contain alot of utility functions,
> auxfns.lisp, where some of the Common Lisp functions are redefined
using
> 'defun'. There is this one function called "Reduce" which gives me
> a debugger prompt, telling me that I'm redefining a Common Lisp
function
> and ask me to type "continue" to accept this action. To solve the
problem
> would be just type in the "continue" as it asked and it'll finish
loading
> successfully.
>
> Now I need to find a way to load that same file without it asking
me
> each time. Is there a special declaration or command that'll let me
> do that? Please! I don't want to type "continue" again!
>
> Rename your function in auxfns.lisp. You do not want to change the
> function definition of a standard CL function. Doing so is guaranteed
> to give you future headaches.

I'm 90% sure that you are talking about the "auxfns.lisp" from Peter
Norvig's book. The reason he redefines "reduce" is to bring it up to the
ANSI standard, which means adding a :KEY keyword to the argumentlist.

So, if you are using a ANSI common lisp which already supports the
extended REDUCE, you can safely comment it out of your auxfns.lisp file.

If you ARE running a pre-ANSI common lisp which doesn't yet support :KEY
in reduce AND you are quite sure you need it, you can redefine it, but
remember that there's a tiny (in this case quite small, I think) that you
can get unexpected behaviour from your system, EVEN though your new
function theoretically only extends the functionality of REDUCE (this is
because your compiler is free to make ANY kind of funny assumptions about
built-in functions).

________________________________________________________________________
Espen J. Vestre, es...@coli.uni-sb.de
Universität des Saarlandes,
Computerlinguistik, Gebäude 17.2
Postfach 1150, tel. +49 (681) 302 4501
D-66041 SAARBRÜCKEN, Germany fax. +49 (681) 302 4351

Martin Rodgers

unread,
May 19, 1994, 5:48:55 AM5/19/94
to
In article <BERGER.94M...@pride.cs.uchicago.edu>
ber...@cs.uchicago.edu "Jeff Berger" writes:

> Now I need to find a way to load that same file without it asking me
> each time. Is there a special declaration or command that'll let me
> do that? Please! I don't want to type "continue" again!
>
> Rename your function in auxfns.lisp. You do not want to change the
> function definition of a standard CL function. Doing so is guaranteed
> to give you future headaches.

If you must rename a standard function, I'd define it an alternate
package. That way, the old function will still be there, but you can
use the "new" definition. It's still messy and could get you into
trouble, but it's less likely to confuse the system.

It's a bit like the advise for Smalltalk programmers: always redefine
a method in a _subclass_, but never in the original class.

--
Martin Rodgers

0 new messages