[racket] `def' ?

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sat May 12 13:32:22 EDT 2012

2012/5/12 Matthias Felleisen <matthias at ccs.neu.edu>:
> On May 12, 2012, at 12:54 PM, Jens Axel Søgaard wrote:
>> The syntax
>>  {john .age}  should evaluate as (person-age john)
>> since john is an instance of a person structure.
>> Using information from structure-type-info I can construct the
>> identifier person-age, but I can not figure how to retrieve the
>> actual accessor without using eval.
>> This means that {john .age} only works in the repl and not
>> in a module context.
>> Any pointers for improving the macro dot (which implements this)
>> is appreciated.
> Since {john .age} is syntax, you might be able to grab the namespace at that
> point and use the namespace for an evaluation.

I tried using namespace-anchor for that purpose, but couldn't figure
out how to.

> ;; ---
> My preferred alternative is to equip structs that should work with this syntax with
> a prop so that I can look up the accessor.

Been down that road before ;-)


/Jens Axel

Posted on the users mailing list.