oo::class
oo::class create name ?definition?
oo::class new ?definition?
Makes a class. The definition is a script of oo::define commands: constructor, destructor, method, variable, superclass, mixin, filter, export, and unexport. A class is an object with the methods create, new, and destroy. cls create NAME ARGS makes an object with a name, and cls new ARGS makes one with a name that ztcl picks.
This page also has oo::object.
Examples
A click on an example runs it in the shell of the page.
oo::class create Note {variable text; constructor {t} {set text $t}; method show {} {return "note: $text"}}:::NoteNote create milk "buy milk"; milk show:note: buy milk
Errors
milk nopegives the errorunknown method "nope": must be destroy or show
Facts
- Capability: none.
- Compute cost: one compute unit for the call, and more for the commands that it runs.