[racket] Dynamically calling struct accessors/method names

From: Todd Bittner (toddbittner at gmail.com)
Date: Tue Sep 6 14:44:57 EDT 2011

Actually, on pondering it for a few more minutes,  your original solution is
sufficient for what I'm trying to do, which is to consolidate a lot of
similar code into one common parent function, but it would be interesting to
know how to call the function if I only had a string.

So, if for argument's sake, I had a file with a list of approved functions
and one of them were 'posn-x', how would I take "posn-x" the string and turn
into posn-x, the accessor call (or function call if it weren't a struct)?

I tried passing variations to eval, but I always wind up with something like
(eval '("posn-x")) or eval'('posn-x)), never the actual function, posn-x.

On Tue, Sep 6, 2011 at 1:32 PM, Matthias Felleisen <matthias at ccs.neu.edu>wrote:

> Are you reading the desired field name from somewhere?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110906/8e47e2f1/attachment.html>

Posted on the users mailing list.