Re: [racket] Dynamically calling struct accessors/method names

2011-09-06 Thread Matthias Felleisen
On Sep 6, 2011, at 2:44 PM, Todd Bittner wrote: > 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 c

Re: [racket] Dynamically calling struct accessors/method names

2011-09-06 Thread Todd Bittner
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

Re: [racket] Dynamically calling struct accessors/method names

2011-09-06 Thread Matthias Felleisen
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 p

Re: [racket] Dynamically calling struct accessors/method names

2011-09-06 Thread Todd Bittner
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 dynam

Re: [racket] Dynamically calling struct accessors/method names

2011-09-06 Thread Matthias Felleisen
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 On Sep 6, 2011, at 2:17 PM, Todd Bittner wrote: > Hi, > > I'm trying to something along the following lines: > > >