[racket] Dynamically calling struct accessors/method names

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Sep 6 14:32:04 EDT 2011

Are you reading the desired field name from somewhere? 



On Sep 6, 2011, at 2:29 PM, Todd Bittner wrote:

> Right, but what I want to do in this case is pass in 'x' and dynamically construct posn-x rather than pass in the accessor 'posn-x' itself.  In other words, I know I want to call a posn accessor, but I don't know which one yet.
> 
> I want to dynamically build and call the method rather than just dynamically call the method.
> 
> On Tue, Sep 6, 2011 at 1:22 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
> 
> In Racket, accessors are functions and are thus perfectly legitimate arguments:
> 
> (define (foo some-posn some-accessor)
>  (some-accessor some-posn))
> 
> > (foo my-posn posn-x)
> 3
> 
> 
> 
> 
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110906/88f737e3/attachment.html>

Posted on the users mailing list.