[racket] have built a symbol, now need the value of the id represented by the symbol

From: Geoffrey S. Knauth (geoff at knauth.org)
Date: Tue Feb 18 15:54:10 EST 2014

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.

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...)

Geoff

line1-gsk: undefined;
 cannot reference undefined identifier
  context...:
   /Users/gknauth/me/2014/taxes/TY2013/ipt-latex.rkt:50:2: for-loop
   /Users/gknauth/me/2014/taxes/TY2013/ipt-latex.rkt:49:0: pr-table-rows
   /Users/gknauth/me/2014/taxes/TY2013/ipt-latex.rkt:35:0: pr-table
   /Users/gknauth/me/2014/taxes/TY2013/ipt-hdr-gsk.rkt: [running body]

ipt-data.rkt:
(provide (all-defined-out))
(define line1-gsk  (round (+ 111 222 333)))
; I want this value, line1-gsk, to be picked up in pr-table-row below

ipt-latex.rkt:
(require (lib "48.ss" "srfi"))
(require "ipt-data.rkt")
(provide (all-defined-out))
...
(define (pr-table-row lineno whoisa whoisb)  ; whoisa is "gsk" (me), whoisb is my spouse
  (let* ((base-str (string-append "line" (number->string lineno) "-"))
         ;;;;;; ERROR FIRST HAPPENS HERE ;;;;;;
	 (amt-a (eval (string->symbol (string-append base-str whoisa))))
         ;;;;;; (eval 'line1-gsk)        ;;;;;;
	 (amt-b (eval (string->symbol (string-append base-str whoisb))))
	 (what  (eval (string->symbol (string-append base-str "what"))))
	 (desc  (eval (string->symbol (string-append base-str "desc")))))
    (printf
     (string-append
      (number->string lineno) "&"
      what "&"
      
      (number->string lineno) "&"
      "\\texttt{" (format "~9,2F" amt-a) "}&"
      "\\texttt{" (format "~9,2F" amt-b) "}"
      (if desc
	  (string-append "\\\\&{\\small " desc "}&&&")
	  "")
      "\\\\\\hline\n"))))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140218/2c874149/attachment.html>

Posted on the users mailing list.