[racket] Run-time record access

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Wed Dec 10 14:15:51 EST 2014

You can generate a struct-accessor-procedure using struct-info, and use
that with integer indexes.

Sam

On Wed Dec 10 2014 at 2:00:34 PM Benjamin Greenman <blg59 at cornell.edu>
wrote:

>  Ok, thank you.
>
>  Is struct->vector the best way to access fields positionally?
>
> On Wed, Dec 10, 2014 at 7:30 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>
>> Currently, the run-time representation of a struct doesn't include
>> field names. In that sense, field names don't exist at run time, and
>> all fields are accessed by position.
>>
>> We plan to change the structure-type core to add field names, but it
>> hasn't happened, yet.
>>
>> At Wed, 10 Dec 2014 04:36:50 -0500, Benjamin Greenman wrote:
>> > I'm hoping to implement the following function to access arbitrary
>> struct
>> > fields.
>> >
>> > ;; Compute `[st]-field-name st`, where
>> > ;; [st] is the name of the struct type of `st`
>> > (define (runtime-get st field-name)
>> >   (-> struct? string? any/c)
>> >   (error "not implemented"))
>> >
>> > Is this possible? I fear I can't use a macro because I don't know
>> exactly
>> > which struct I'll get at runtime.
>>   > ____________________
>> >   Racket Users list:
>> >   http://lists.racket-lang.org/users
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20141210/0cc13c3c/attachment.html>

Posted on the users mailing list.