NB. The stack object template which inherits a print method data =: '' stack_z_ =: monad define ('method' ; 'value') =. 2 take y. if. method match 'type' do. 'stack' elseif. method match 'emptyp' do. 0 = tally data elseif. method match 'push' do. for_effect_only data =: (box value) , data elseif. method match 'top' do. if. 0 = tally data do. 'top: stack is empty' else. open first data end. elseif. method match 'pop' do. if. 0 = tally data do. 'pop: stack is empty' else. for_effect_only data =: rest data end. elseif. method match 'size' do. tally data elseif. method match 'print' do. if. 0 = tally data do. 'print: stack is empty' else. for_effect_only display 'top of stack' print 'print' ; box data end. elseif. 1 do. root_object method ; value end. )