<div dir="ltr"><div>Could you use a dictionary (e.g., hash table) instead of `define`s by any chance? Then you would not need `eval` but only `dict-ref`, which is way less problematic.<br><br></div>Laurent<br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Feb 18, 2014 at 9:54 PM, Geoffrey S. Knauth <span dir="ltr"><<a href="mailto:geoff@knauth.org" target="_blank">geoff@knauth.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Our local community has a funky tax form not handled by the big tax prep vendors. So I rolled my own with Racket. It outputs LaTeX so I have something to submit all ready.<div><br></div>
<div>Well it would, except I have goofed something up. I'm eval'ing a symbol (probably incorrect). The symbol comes not from the top-level, but from a module. I'm forming a symbol 'line1-gsk. I want the value of the identifier represented by that symbol. How do I do that? (If my son were back from school, I'd ask him...)</div>
<div><br></div><div>Geoff</div><div><br></div><div><span style="font-family:Monaco;font-size:small">line1-gsk: undefined;</span></div><div><font face="Monaco"> cannot reference undefined identifier<br> context...:<br> /Users/gknauth/me/2014/taxes/TY2013/ipt-latex.rkt:50:2: for-loop<br>
/Users/gknauth/me/2014/taxes/TY2013/ipt-latex.rkt:49:0: pr-table-rows<br> /Users/gknauth/me/2014/taxes/TY2013/ipt-latex.rkt:35:0: pr-table<br> /Users/gknauth/me/2014/taxes/TY2013/ipt-hdr-gsk.rkt: [running body]<br>
</font><div><font face="Monaco"><br></font></div><div style="font-size:14px"><font style="font-size:12px" face="Monaco">ipt-data.rkt:</font></div><div><font face="Monaco">(provide (all-defined-out))<br></font><font face="Monaco">(define line1-gsk (round (+ 111 222 333)))</font></div>
<div><font face="Monaco"><font>; I want this value, line1-gsk, to be picked up in pr-table-row below</font><br></font><div><font face="Monaco"><br></font></div><div style="font-size:14px"><span style="font-size:12px;font-family:Monaco">ipt-latex.rkt:</span></div>
</div><div><font face="Monaco">(require (lib "48.ss" "srfi"))<br>(require "ipt-data.rkt")<br>(provide (all-defined-out))<br>...</font></div><div><font face="Monaco">(define (pr-table-row lineno whoisa whoisb) ; whoisa is "gsk" (me), whoisb is my spouse<br>
(let* ((base-str (string-append "line" (number->string lineno) "-"))</font></div><div><font face="Monaco"> ;;;;;; ERROR FIRST HAPPENS HERE ;;;;;;<br><span style="white-space:pre-wrap"> </span> (amt-a (eval (string->symbol (string-append base-str whoisa))))</font></div>
<div><font face="Monaco"> ;;;;;; (eval 'line1-gsk) ;;;;;;<br><span style="white-space:pre-wrap"> </span> (amt-b (eval (string->symbol (string-append base-str whoisb))))<br><span style="white-space:pre-wrap"> </span> (what (eval (string->symbol (string-append base-str "what"))))<br>
<span style="white-space:pre-wrap"> </span> (desc (eval (string->symbol (string-append base-str "desc")))))<br> (printf<br> (string-append<br> (number->string lineno) "&"<br> what "&"<br>
<br> (number->string lineno) "&"<br> "\\texttt{" (format "~9,2F" amt-a) "}&"<br> "\\texttt{" (format "~9,2F" amt-b) "}"<br>
(if desc<br><span style="white-space:pre-wrap"> </span> (string-append "\\\\&{\\small " desc "}&&&")<br><span style="white-space:pre-wrap"> </span> "")<br> "\\\\\\hline\n"))))</font></div>
</div></div><br>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></blockquote></div><br></div>