From: William James
Subject: Redefining +
Date: 
Message-ID: <a7176b59-2b08-43ee-b427-80e1b336e8b5@x16g2000prn.googlegroups.com>
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

From: blandest
Subject: Re: Redefining +
Date: 
Message-ID: <d533bbae-fe12-496b-8820-9a269d0b28fc@1g2000prd.googlegroups.com>
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 ?
From: ·······@eurogaran.com
Subject: Re: Redefining +
Date: 
Message-ID: <906a3b15-99ce-4294-adb2-e1a69d0beb8f@r37g2000prr.googlegroups.com>
Is it possible to convert it into a variadic operator?
variadic=able to admit any number of arguments, not just two:
+ 3 4 7 2 -> 16