You can generate a struct-accessor-procedure using struct-info, and use that with integer indexes.<br><br>Sam<br><br><div class="gmail_quote">On Wed Dec 10 2014 at 2:00:34 PM Benjamin Greenman <<a href="mailto:blg59@cornell.edu">blg59@cornell.edu</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div dir="ltr">
<div class="gmail_extra">Ok, thank you.</div>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">Is struct->vector the best way to access fields positionally?</div></div></div><div><div dir="ltr">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Dec 10, 2014 at 7:30 AM, Matthew Flatt <span dir="ltr">
<<a href="mailto:mflatt@cs.utah.edu" target="_blank">mflatt@cs.utah.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Currently, the run-time representation of a struct doesn't include<br>
field names. In that sense, field names don't exist at run time, and<br>
all fields are accessed by position.<br>
<br>
We plan to change the structure-type core to add field names, but it<br>
hasn't happened, yet.<br>
<div>
<div><br>
At Wed, 10 Dec 2014 04:36:50 -0500, Benjamin Greenman wrote:<br>
> I'm hoping to implement the following function to access arbitrary struct<br>
> fields.<br>
><br>
> ;; Compute `[st]-field-name st`, where<br>
> ;; [st] is the name of the struct type of `st`<br>
> (define (runtime-get st field-name)<br>
> (-> struct? string? any/c)<br>
> (error "not implemented"))<br>
><br>
> Is this possible? I fear I can't use a macro because I don't know exactly<br>
> which struct I'll get at runtime.<br>
</div>
</div>
<div>
<div>> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div></div></blockquote></div>