From: Steven D. Majewski
Subject: generic functions to redefine builtin functions - how ?
Date: 
Message-ID: <DCyqHs.L2u@murdoch.acc.Virginia.EDU>
Is this any easier in CLOS ? 

  I've been futzing around with three different more-or-less 
working methods plus quite a few non-working methods before 
figuring out that SHADOW was what I needed to be able to redefine
a built-in and inherited primitive within my package:

	( make-package "GENERIC-SEQUENCES" 
		:nicknames '( "GENSEQ" ) :use '(LISP ))
	( in-package "GENSEQ" )

	( shadow '( length elt ))

And SHADOWING-IMPORT if I want to make it the default in the USER
package. ( Unfortunately, none of the half-dozen Lisp books I had
on hand went into Packages in any depth, except for CLTL - which 
had all of the definitions, and provides a good explaination of 
why the things that finally worked *did* work, but wasn't a very
good guide to figureing out what those things might be - i.e. a 
typical reference manual. ;-) 

I have been working in Xlisp (Xlisp-Stat), which except for a non
CLOS object system, is close enough to Common Lisp, and I've
been cross testing some of my routines in AKCL, to check their
Common Lisp conformance. ( Note that *some* variations of syntax 
and defaults equivalent to the above won't be QUITE equivalent in
both Lisp's ) 


To translate what I've been trying to do into more generic language,
I've been trying to define an object that is 'plug-replacable' for
other sequences like conses and vectors, but that carries along some
extra information and methods. ( XLISP-STAT specifically: extending
LENGTH and ELT to work with COMPOUND-DATA-PROTO's ) 

[ Perhaps the "ancient and traditional" LISP method to do something
 similar is to use properties, but since properties are properties
 of SYMBOLS and not of values, this doesn't work well for my needs. ] 

This redefinition appears to work, except that I've found one instance
where I had to explicitly change "LENGTH" to "LISP:LENGTH" in code
that was loaded after the redefinition - this was when the LENGTH
was part of an expression in the default for a lambda list - for all
instances in the body of the function, the redefined LENGTH seemed to
work properly. 

 This interface problem between the built-in objects and class based
objects seems to be a troubled spot in impure/mixed object-oriented 
languages ( Well- it is in C++ anyway ... Python's solution works pretty
well. ) 

  Is this any easier in CLOS ? Do generic functions provide a way to
do this ? ( None of the CLOS books I've looked at provide a hint of
how to do this, although I would think it's a common problem. ) 


---|  Steven D. Majewski   (804-982-0831)  <·····@Virginia.EDU>  |---
---|  Computer Systems Engineer          University of Virginia  |---
---|  Department of Molecular Physiology and Biological Physics  |---
---|  Box 449 Health Science Center    Charlottesville,VA 22908  |---
 [ "The grass is always greener, except at t=0" - Stan Kelly-Bootle ]