The following racket function produces the error:
reference to undefined identifier: val
This is because the eval function looks at the global namespace, not the local function’s namespace. How do I trick eval into using the local function’s namespace?
(define some-eval!
(lambda (val row col)
(eval (list 'define 'ttboard '(list-builder val row col))) (current-namespace) ))
You can define
ttboardahead of time and thenset!it:That way, you can clearly tell that
ttboardis a global variable, rather than having its definition obscured in an eval’d clause.