Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing an ordinary function with a generic function

I'd like to use names such as elt, nth and mapcar with a new data structure that I am prototyping, but these names designate ordinary functions and so, I think, would need to be redefined as generic functions.

Presumably it's bad form to redefine these names?

Is there a way to tell defgeneric not to generate a program error and to go ahead and replace the function binding?

Is there a good reason for these not being generic functions or is just historic?

What's the considered wisdom and best practice here please?

like image 784
Rob Blackwell Avatar asked Dec 07 '22 22:12

Rob Blackwell


1 Answers

If you are using SBCL or ABCL, and aren't concerned with ANSI compliance, you could investigate Extensible Sequences:

http://www.sbcl.org/manual/#Extensible-Sequences

http://www.doc.gold.ac.uk/~mas01cr/papers/ilc2007/sequences-20070301.pdf

...you can't redefine functions in the COMMON-LISP package, but you could create a new package and shadow the imports of the functions you want to redefine.

like image 85
Greg Buchholz Avatar answered Jan 09 '23 11:01

Greg Buchholz