I am trying something out in Scheme for fun. I'm trying to make an Area function that gets the type of the thing it's operating on and then calls a different function depending on the type of object. Here's my code:
(define (area object)
(if (not (null? (eval (word 'area- (get-type object)))))
(eval (list (word 'area- (get-type object)) 'object))
#f
)
)
Scheme doesn't like this because it says object is an unbound variable. No, I can't take the quote away because then it's actually placing the value there and then Scheme complains that the list is malformed.
What can I do to use the value in object within eval?
Note: Scheme apparently grabs the global variable "object" just fine, so it's basically ignoring that it's inside a function.
Some information for a related language is here: http://docs.racket-lang.org/guide/eval.html, which seems to indicate that there isn't a solution in Scheme, but if you know of one I'd like to hear it.