[racket] A safe version of unsafe-struct-ref [for Whalesong]

From: J. Ian Johnson (ianj at ccs.neu.edu)
Date: Wed Jul 2 15:18:25 EDT 2014

Whoops, make that reverse order, BUT you should be able to infer how many fields you should expect by the struct's pattern. You should of course double check with the list of field accessors (if the last entry isn't #f). Otherwise, you may just emit bad code. That said, I'm not sure how not-bad the corresponding unsafe-struct-ref would be :P
-Ian
----- Original Message -----
From: "J. Ian Johnson" <ianj at zimbra.ccs.neu.edu>
To: "Jens Axel Søgaard" <jensaxel at soegaard.net>
Cc: "racket" <users at racket-lang.org>
Sent: Wednesday, July 2, 2014 3:15:25 PM GMT -05:00 US/Canada Eastern
Subject: Re: [racket] A safe version of unsafe-struct-ref [for Whalesong]

You can use extract-struct-info to get the field accessors in order, so you can list-ref that list to get the function you need for an unsafe-struct-ref.

However, bullet 4 of

http://docs.racket-lang.org/reference/structinfo.html

says sometimes you can't get all the accessors. Happy hacking.
-Ian
----- Original Message -----
From: "Jens Axel Søgaard" <jensaxel at soegaard.net>
To: "racket" <users at racket-lang.org>
Sent: Wednesday, July 2, 2014 3:06:50 PM GMT -05:00 US/Canada Eastern
Subject: [racket] A safe version of unsafe-struct-ref [for Whalesong]

Is it possible to implement unsafe-struct-ref using safe constructs only?

The reason behind this peculiar question, is that I am porting racket/match
to Whalesong. The match compiler uses various unsafe constructs that Whalesong
doesn't implement. It is straightforward to replace, say,
unsafe-vector-ref with vector-ref.

But unsafe-struct-ref ?

It is okay to use all tricks in the book in phase 1 (Whalesong has
restrictions in phase 0 only).

/Jens Axel
____________________
  Racket Users list:
  http://lists.racket-lang.org/users


Posted on the users mailing list.