[racket] What do first-class structures achieve?
Hi,
The documentation says that struct creates structures that are treated as
first-class
values. I can see the motivation for pursuing expressiveness. So what do we
achieve
using first-class structures? On the down side, I see some problems. For
example, in
the Beginning Student language, a posn is both a posn? and a struct?.
> (posn? (make-posn 1 2))
#t
> (struct? (make-posn 1 2))
#t
I guess this is because posn is declared to be #:transparent.
In my opinion, exposing the struct? nature of posn undermines abstraction
and breaks
encapsulation. But without declaring it #:transparent, the printer could
not echo
informative response. It seems to me the two aspects: exposing the
struct?nature and
informative result are unnecessarily tangled. If they can be separated, we
may be able
to give informative result and at the same time not to expose the
struct?nature of
structure types.
Best,
Yi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140313/42217e8c/attachment.html>