[plt-scheme] How to find the value associated to a symbol via an identifier ?

From: Grant Rettke (grettke at acm.org)
Date: Mon Feb 16 17:49:11 EST 2009

On Sun, Feb 15, 2009 at 10:12 PM, Eli Barzilay <eli at barzilay.org> wrote:
> On Feb 15, Grant Rettke wrote:
>> Is there a not-ugly non-macro-generating way to do this?
>
> No, at least not for my definition of "not-ugly".  And there's a
> reason for that: questions like this are always about something that
> could be done in a better way.

I think this is a "macros for macros sake question".

I see that this is a literal approach:

#lang scheme

(define id45 45)
(define idid 'id45)

(define-syntax find-symbol-value
 (lambda (stx)
   (syntax-case stx ()
     ((find-symbol-value)
      (with-syntax
          ((var (datum->syntax #`find-symbol-value 'id45 #f)))
        #`var)))))

(find-symbol-value)

But none of what I have studied or learned (yet?) helps me understand
how to easily generalize the solution. How would you do that?


Posted on the users mailing list.