oo::define
oo::define className arg ?arg ...?
Changes the definition of a class. A change goes to each object of the class at once.
This page also has oo::define::constructor, oo::define::deletemethod, oo::define::destructor, oo::define::export, oo::define::filter, oo::define::forward, oo::define::method, oo::define::mixin, oo::define::renamemethod, oo::define::self, oo::define::superclass, oo::define::unexport, oo::define::variable.
Subcommands
| Synopsis | What it does |
|---|---|
constructor ARGS BODY |
The code that runs when an object is made. |
destructor BODY |
The code that runs when an object is removed. |
method NAME ARGS BODY |
A method. A name that starts with a lowercase letter is exported. |
variable ?NAME ...? |
Variables that each method sees with no my variable. |
superclass ?CLASS ...? |
The parent classes. |
mixin ?CLASS ...? |
Classes whose methods come before the methods of the class. |
filter ?METHOD ...? |
Methods that run around each call. |
forward NAME CMD ?ARG ...? |
A method that runs a command. |
export NAME ?NAME ...? |
Makes methods callable from outside. |
unexport NAME ?NAME ...? |
Makes methods callable only with my. |
deletemethod NAME ?NAME ...? |
Removes methods. |
renamemethod OLD NEW |
Gives a method a new name. |
self SCRIPT |
Changes the definition of the class object itself. |
Examples
A click on an example runs it in the shell of the page.
oo::class create A; oo::define A method hi {} {return hi}; [A new] hi:hi
Facts
- Capability: none.
- Compute cost: one compute unit for the call, and more for the commands that it runs.