up previous next
1.6.7 Tagging an Object
***** NOT YET UPDATED TO CoCoA-5: follow with care *****

If E is any CoCoA object and S a string, then the function Tagged(E, S) returns the object E tagged with the string S. The type of the returned object is TAGGED(S) (but the type of E is unchanged). The function tag returns the tag string of an object, and the function untagged (or @ ) returns the object, stripped of its tag.

Example
  L := ["Dave","March 14, 1959",372];
  M := Tagged(L, "MiscData");  -- L has been tagged with the string "MiscData"
  type(L);  -- L is a list
LIST
-------------------------------
  type(M);  -- M is a tagged object
TAGGED("MiscData")
-------------------------------
  Tag(M); -- the tag string of M (it would be the empty string if M
          -- were not a tagged object).
MiscData
-------------------------------
  M;  -- Until a special print function is defined, the printing of L
      -- and M is identical.
["Dave", "March 14, 1959", 372]
-------------------------------
  Untagged(M) = L; -- "untagged" removes the tag from M, recovering L.
True
-------------------------------
The next section explains how to define functions for pretty printing of tagged objects.