How to print structures in PLT Scheme so as to display their fields? -
I want a code like this:
(define-struct thing (abc)) (To print something like this (object object 1 2 3)) Define
:
(Messe-cheese 1 2 3 )
When I type "th" then either Dr. In the scheme or MSSKM rip I set "creative" with the output style of Dr. I am using the "very big" language in the schema.
(make-cheese ...)
(I really get three points)
in MzScheme:
# & lt; Object & gt;
There are several ways to do this, to use the most obvious one:
(Defined Structure Object (ABC)):
What makes the structure accessible to low-level inspection that printouts is another option Using your own printer:
(define-struct thing (abc) #: Support of property: custom-writing (lambda (write thing port?) (Fprintf port (if write Have (Cheese-one thing) (cheese-cheese) (cheese-cheese)))
"{~ s, ~ s, ~ s}" "{~ a, ~ a, ~ a}" )
But note that the "constructor" output style tries to write some things differently, also keep in mind that you can add both of these to your own writer and transparent. (Making it transparent is possible to access the field in the object
example for any code, for example, equals?
can dig into it.) < Finally, some more features are used to use "FIFA" strings for some:
(define-struct thing (abc) #: Prefab)
What usually happens is that each defined-structure
generates a new type, even if no initiative Be defined. But with a prefab strait, it seems that there is a type already present and you are compelling some functions (constructor, point and accessories) to work with this retro type type.
Comments
Post a Comment