On Thu, 30 Jan 2003, Wayne O. Cochran wrote:
> > your problem comes from redefining a standard Common Lisp function.
> 
> There were also a couple of suggestions to place max 
> in a different namespace or give it another name, and
> of course I could do that. The students also suggested
> the aforementioned namespace collision with a builtin.
> My response way "bah" -- Lisp allows you to redefine
> functions -- even the builtin ones (although this is
> not generally a good idea). To be a language lawyer,
> here is a quote from Steel's "Common Lisp," sec 5.3.1, p.85.
> 
>   "It is permissible to use defun to redefine a function,  
>   to install a corrected version of an incorrect definition,
>   for example. It is permissible to redfine a macro as
>   a function."
Yeah, but the Hyperspec explicitly forbids redefining anything in the
COMMON-LISP package.
 
> If one could not redefine the builtin functions then
> one would have to keep mental track of the very large
> set of functions, macros, etc... that are predefined
> in Lisp. 

But these symbols are all in the Common Lisp package.  You shouldn't
redefine functions in the other CMUCL implementation packages either, but
you're not as likely to do that because they aren't used by your packages
by default.

> 
> Also, even if one could not redefine the builtin
> functions, the problem should manifest itself
> at definition time:
> 
> * (defun max (a b) (if (> a b) a b))
> MAX
> * #'max
> #<Interpreted Function MAX {4801E451}>
> 
> Everythings seems fine at this point. Shouldn't
> I have at least been issued a warning of some sort?!?

I believe Eric posted some code showing how to force errors in this case.
Other Lisp implementations do have "locked packages" and signal this kind
of error.  We've talked about signalling this kind of error by default in
CMUCL; I don't remember what the consensus was.

> 
> > You created an infinite regress. 
>   
> Assuming what I did was wrong, I am a little bit curious
> as to how this manifested itself. I have a hard time
> seeing how this could have triggered an "infinite regress."
> Either my max or the system's max should have been invoked.
> Can anyone explain how the system could have been
> confused into issuing multiple recursive calls?

I don't have my CMUCL sources close at hand, but this is the most likely
possibility: Your MAX is interpreted.  MAX is likely being called by the
interpreter.

Tim



Reply via email to