Frank Buss wrote:
> Steven D'Aprano wrote:
> > Yes. But you can't redefine 1+2 in Python, at least not without hacking
> > the interpreter. Can you redefine (+ 1 2) in Lisp?
>
> Yes, that's no problem and works without warnings and in every Common Lisp
> implementation:
>
> CL-USER > (shadow '+)
> T
>
> CL-USER > (defun + (&rest rest) (apply #'- rest))
> +
>
> CL-USER > (+ 3 1)
> 2
class Fixnum
def + other
self - other
end
end
==>nil
9 + 2
==>7
On Nov 3, 6:08 pm, William James <·········@yahoo.com> wrote:
> Frank Buss wrote:
> > Steven D'Aprano wrote:
> > > Yes. But you can't redefine 1+2 in Python, at least not without hacking
> > > the interpreter. Can you redefine (+ 1 2) in Lisp?
>
> > Yes, that's no problem and works without warnings and in every Common Lisp
> > implementation:
>
> > CL-USER > (shadow '+)
> > T
>
> > CL-USER > (defun + (&rest rest) (apply #'- rest))
> > +
>
> > CL-USER > (+ 3 1)
> > 2
>
> class Fixnum
> def + other
> self - other
> end
> end
> ==>nil
>
> 9 + 2
> ==>7
Is it possible to redefine + for strings too ?