printing - How can I teach Tcl to automatically print my object with a proc I provide? -
i have object tcl shows in console being object id. how can extend tcl such whenever objects of type printed, special proc automatically called provide print contents instead of giving object id?
some more details: emulating lisp list in tcl built out of cons cells each have car , cdr. list of 1 "two" 3 created with:
(cons 1 (cons "two" (cons 3 nil)))
which creates 3 cons cells. top cons cell has 1 in car has pointer second cons cell has "two" in car, etc.
with representation, wish above sample list print out as:
(1 "two" 3)
i assume you're working @ c level. basically, register function in tcl_objtype
structure, in updatestringproc
field. function need produce string rendering of overall value (stored in ckalloc
ed string in bytes
field of tcl_obj
); how you.
Comments
Post a Comment