[plt-scheme] Renaming +, -, *, /

From: Eric Hanchrow (offby1 at blarg.net)
Date: Sun Oct 9 18:29:32 EDT 2005

Here's how I'd do it: put this into a file named "hmm.ss":
----------------------------------------
(module hmm mzscheme
  (provide (all-from-except mzscheme +))
  (provide (rename my-+ +))
  (define (my-+ . args)
    (printf "Adding ~s!~%" args)
    (apply + args)))
----------------------------------------
Now to test it: put this into a file named anything you like:
----------------------------------------
(require "hmm.ss")
(display " 3 + 4 is ... ")
(display (+ 3 4))
(newline)
----------------------------------------

Now run the test: 

$ mzscheme -qr anything-you-like.ss
 3 + 4 is ... Adding (3 4)!
7
$ 

-- 
A DRE voting system is one of the simplest computer
applications you could imagine.  It just adds by one.
        -- Brit Williams, emeritus professor of computer science


Posted on the users mailing list.