Classes and instances can be examined in two ways. For a class, you can simply type the name at the prompt. Instances of classes bound to C structures can be viewed using the instance_vars function. To examine an instance of a class, simply type an expression which evaluates to that instance ( see, for example, elephant as an instance of the animal class in the Instances section of the Class chapter).
You can examine not only user-defined classes, but also the classes which are implemented in Gamma. For example,
Gamma> PhImage; # < Binary Class: PhImage > Gamma> instance_vars (PhImage); [bpl colors flags format image image_tag palette palette_tag size \ type xscale yscale] Gamma> x = new (PhImage); {PhImage (bpl . 0) (colors . 0) (flags . 0) (format . 0) \ (image . #{}) (image_tag . 0) (palette . []) (palette_tag . 0) \ (size . {PhDim (h . 0) (w . 0)}) (type . 0) (xscale . 0) \ (yscale . 0)} Gamma> x; {PhImage (bpl . 0) (colors . 0) (flags . 0) (format . 0) \ (image . #{})(image_tag . 0) (palette . []) (palette_tag . 0) \ (size . {PhDim (h . 0) (w . 0)}) (type . 0) (xscale . 0) \ (yscale . 0)} Gamma> instance_vars (x); [(bpl . 0) (colors . 0) (flags . 0) (format . 0) (image . #{}) \ (image_tag . 0) (palette . []) (palette_tag . 0) (size . \ {PhDim (h . 0) (w . 0)}) (type . 0) (xscale . 0) (yscale . 0)] Gamma> pretty_princ (x, "\n"); {PhImage (bpl . 0) (colors . 0) (flags . 0) (format . 0) (image . #{} )) (image_tag . 0) (palette . []) (palette_tag . 0) \ (size . {PhDim (h . 0) (w . 0)}) (type . 0) (xscale . 0) \ (yscale . 0)} t
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.