::oo::class Core 8.6
::oo::copy Core 8.6
::oo::define Core 8.6
::oo::objdefine Core 8.6
::oo::object Core 8.6
::oo::util Tcllib 1.18
::oo::dialect Tcllib 1.18
::oo::meta Tcllib 1.18
::oo::option Tcllib 1.18
::info Core
::info class Core 8.6
::info object Core 8.6
::my Core 8.6
::next Core 8.6
::self Core 8.6
namespace import oo::*
proc noop args {}
# ***Instantiation***
class create A1class
A1class create a1object
class create B1class
set b1object [B1class new]
#-----
object create c1object
set d1object [object new]
#-----
# ***Construction***
class create A2class {
constructor args {
puts hi
catch {next $args} {}
}
}
class create B2class
define B2class constructor args {
puts hi
catch {next $args} {}
}
A2class create a2object
B2class create b2object
#-----
# ***Variables and methods***
class create A3class {
constructor args {
variable a
catch {next $args} {}
}
method a1method arg {
variable a
set a $arg
}
method a2method {} {
variable a
return $a
}
}
class create B3class {
variable b
method b1method arg {
set b $arg
}
method b2method {} {
return $b
}
}
class create C3class
define C3class variable c
define C3class method c1method arg { set c $arg }
define C3class method c2method {} { return $c }
A3class create a3object
a3object a1method 5
puts [a3object a2method]
set b3object [B3class new]
$b3object b1method 5
puts [$b3object b2method]
#-----
# ***Inheritance***
class create A4class {
variable a
constructor arg {
set a $arg
catch {next $arg} {}
}
method a1method {} {
return $a
}
}
class create B4class {
variable b
constructor arg {
set b $arg
catch {next $arg} {}
}
method b1method {} {
return $b
}
}
noop Single Inheritance
class create C4class {
superclass A4class
constructor arg {
catch {next $arg} {}
}
method c1method {} {
my variable a
return $a
}
}
noop Multiple Inheritance
class create D4class {
superclass B4class C4class
constructor arg {
catch {next $arg} {}
}
}
C4class create c4object hi
puts [c4object c1method]
puts [c4object a1method]
set d4object [D4class new 42]
puts [$d4object c1method]
puts [$d4object b1method]