[plt-scheme] help - a simple dispatcher problem

From: actuary77 at comcast.net (actuary77 at comcast.net)
Date: Mon Dec 6 21:51:09 EST 2004

I am trying to write a simple dispatcher and I am having scoping problems:
The idea is to look up a symbol in a list:

(define a '(x y z))      ; list to be used for lookup
(define b '(i j k))

(define (afunc)

   (define (dispatch m)     ;  dispatch
     (let ((arg m))
       (define (lookup n)     ;   lookup
	(let ((the-list arg))	
	  (set! arg m)
	  (pp the-list)
	(list-ref the-list n)))


   (define myfunc (afunc))
   (define newfunc (myfunc 'a))
   (newfunc 1))

==>  returning error - 1 is not a list
      it appears that the list a is being
	redefined by the symbol 'a or??


How can I rewrite to recognize the symbol a
passed to myfunc as the orginial definition a?

If this makes any sense.


David Koch
actuary77 at comcast.net

Posted on the users mailing list.