up previous next
2.16.2 Printing a Tagged Object
Suppose the object E is tagged with the string S . When one tries to print E ---say with Print E --- CoCoA looks for a user-defined function with name Print_S . If no such function is available, CoCoA prints E as if it were not tagged, otherwise, it executes Print_S .

Example
/**/  L := ["Dave", "March 14", 1959, 372];
/**/  M := tagged(L,"MiscData");

/**/  Define SpecialPrinting(Dev, Obj)
/**/    Print Obj[1],"'s birthday is: ", Obj[2] on Dev;
/**/  EndDefine;

/**/  PrintTagged := record[MiscData := SpecialPrinting];

/**/  Print M;
Dave's birthday is: March 14