Poet2.2 Manual Prototype Object Extension for Tcl

Examples

As a preface to studying the Poet commands, here are some simple examples.

Example 1: We define two objects, a and b, where a is b's parent. We define a method for a, which is inherited by b.

% package require Poet
2.2
% Object construct a
a
% a construct b
b
% a method foo {} {puts "Hello"}
% a foo
Hello
% b foo
Hello
%

Example 2: We define two objects, a and b, where a is b's parent. a is given a slot called name. Note how b's name slot is inherited from a, until we give it a new value.  When we remove b's copy of the slot with unslot, we revert to a's value for the slot.

% package require Poet
2.2
% Object construct a
a
% a slot name "The Letter A"
% a slot name
The Letter A
% a construct b
b
% b slot name
The Letter A
% b slot name "The Letter B"
The Letter B
% b slot name
The Letter B
% a slot name
The Letter A
% b unslot name
% b slot name
The Letter A
%