<div>evaluate string which contains many definitions</div><div><br></div><div>hello~</div><div><br></div><div>I don't know why the following code doesn't working at all</div><div><br></div><div>I can eval a-value but not b-func nor c-value</div>
<div><br></div><div>#lang scheme</div><div>(require racket/gui)</div><div>(require 2htdp/batch-io)</div><div>(define-namespace-anchor anchor)</div><div>(define ns (namespace-anchor->namespace anchor))</div><div>(define content (read-file "./eval.txt"))</div>
<div><br></div><div>(eval (read (open-input-string content)) ns)</div><div><br></div><div>(eval 'a-value ns)</div><div>(eval '(b-func) ns)</div><div>(eval 'c-value ns)</div><div><br></div><div><br></div><div>===content of eval.txt===</div>
<div>(define a-value 0)</div><div>(define (b-func)</div><div> (* 2 2))</div><div>(define c-value 3)</div><div>=========================</div><div>I expected </div><div>0 </div><div>4 </div><div>3 </div><div>as a result but </div>
<div> reference to an identifier before its definition: b-func</div><div>arises</div><div><br></div>