[racket] Dynamically calling struct accessors/method names

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

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/be15ca51/attachment.html>

Posted on the users mailing list.