[racket] `def' ?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat May 12 13:01:55 EDT 2012

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. 

;; --- 

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

-- Matthias




Posted on the users mailing list.