[plt-scheme] Catch an unknown method error

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Feb 21 08:01:20 EST 2008

On Feb 21, 2008, at 4:55 AM, Filipe Cabecinhas wrote:

> I'm a CLer and haven't got around the whole hygienic macro thing.

The macro hygiene part is completely, totally non-intrusive. You  
don't notice it except that your macro functions properly in all  
cases, including things like this

   (lambda (x)
      (printf "No such method: ~a for object ~a with args: ~a,  
forwarding.~%" 'name obj args)
      (send/apply exp forward-invocation 'name args)))

Your macro uses x here to bind the exception. The exp part however  
comes from your macro user (you for the moment). Just imagine, cruel  
thought, that the macro user uses the new send macro like this:

  (send x print)

meaning exp = x. Can you guess what would happen in the world of CL?

;; ---

I think Noel's code is doing some hygiene by hand for you (why?).  
He's also factoring the macro so that it becomes more readable and  
hygiene(2) ensures that the names are always referring to these  
module-local function definitions.

;; ---

I'd consider moving the forwardable? test into the handler. It just  
looks wrong as it is on the exn discovery side.

-- Matthias

Posted on the users mailing list.