[racket] `immutable?` for `struct`s?

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Sat Jan 25 18:33:49 EST 2014

Yes, #:transparent means "reflective tools like struct? and struct-info can
see inside it".  Otherwise, the short answer is they can't.  If you want to
be able to tell things like immutability via dynamic tests, you have to use
#:transparent for everything.  It also controls how equal? works, among
other things -- with #:transparent, equal? descends recursively into
fields; without #:transparent, equal? just checks eq?.

If using #:transparent is a problem for some reason, we can discuss
alternatives, of which I can think of two or three, but they're more
complicated.  Most likely, #:transparent is the way to go.

Carl Eastlund


On Sat, Jan 25, 2014 at 6:25 PM, Greg Hendershott <greghendershott at gmail.com
> wrote:

> > skipped? = #t can only arise if some struct type in the hierarchy is
> opaque,
> > which would mean struct? returns #f.  If you only care about types that
> > satisfy struct?, you should be able to safely ignore skipped?, if I
> > understand it correctly.
>
> Opaque here means, not declared with #:transparent?
>
> If so, that would explain something else: The units tests I posted
> used #:transparent only because copy-pasta. After I posted, I decided
> to fix that...but then the immutable tests failed. That didn't make
> much sense to me, but I guess now it does.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140125/c4a957be/attachment-0001.html>

Posted on the users mailing list.