Lack of transparent structures?

I noticed that structures in Racket are not transparent by default. It seems strange to me, as in my (limited) experience, when you want to see the value of something, you would like to view its contents! In particular, I mean the use of a keyword / mechanism #:transparentin determining the structure.

Why does Racket have default opaque structures? My only suggestion is that they prevent too much content from being displayed on the console if you show or evaluate a very large structure for some reason.

+4
source share
1 answer

From docs, it seems that the default structures are opaque to encourage more modular programs. When transparent structures are provided, they automatically supersede the internal representation.

Structure types are opaque by default, since instances of an opaque structure provide more encapsulation guarantees. That is, the library can use an opaque structure to encapsulate data, and library clients cannot manipulate data in the structure, except for those allowed by the library.

+6
source

All Articles