Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,21 @@
package require TclOO
# This is a metaclass, a class that defines the behavior of other classes
oo::class create singleton {
superclass oo::class
variable object
unexport create ;# Doesn't make sense to have named singletons
method new args {
if {![info exists object]} {
set object [next {*}$args]
}
return $object
}
}
singleton create example {
method counter {} {
my variable count
return [incr count]
}
}

View file

@ -0,0 +1,14 @@
% set a [example new]
::oo::Obj20
% set b [example new] ;# note how this returns the same object name
::oo::Obj20
% expr {$a == $b}
1
% $a counter
1
% $b counter
2
% $a counter
3
% $b counter
4