link image
May 2, 2001; Michael Glass, Ralph E. Griswold, and David Yost
This file is in the public domain.
The procedure Image(x,style) produces a string image of the value x. The value produced is a generalization of the value produced by the Icon function image(x), providing detailed information about structures. The value of style determines the formatting and order of processing: 1 indented, with ] and ) at end of last item (default) 2 indented, with ] and ) on new line 3 puts the whole image on one line 4 as 3, but with structures expanded breadth-first instead of depth-first as for other styles. ____________________________________________________________ Tags are used to uniquely identify structures. A tag consists of a letter identifying the type followed by an integer. The tag letters are L for lists, R for records, S for sets, and T for tables. The first time a structure is encountered, it is imaged as the tag followed by a colon, followed by a representation of the structure. If the same structure is encountered again, only the tag is given. An example is a := ["x"] push(a,a) t := table() push(a,t) t[a] := t t["x"] := [] t[t] := a write(Image(t)) which produces T1:[ "x"->L1:[], L2:[ T1, L2, "x"]->T1, T1->L2] On the other hand, Image(t,3) produces T1:["x"->L1:[],L2:[T1,L2,"x"]->T1,T1->L2] Note that a table is represented as a list of entry and assigned values separated by ->. ____________________________________________________________ Problem: The procedure here really is a combination of an earlier version and two modifications to it. It should be re-organized to combine the presentation style and order of expansion. Bug: Since the table of structures used in a call to Image is local to that call, but the numbers used to generate unique tags are static to the procedures that generate tags, the same structure gets different tags in different calls of Image.