abstract(n)
β¨ abstract(n) β the TclOO commands glow-up β¨
okay bestie, this one's from TclOO, and it's literally the manual page for oo::abstract. yes the whole page. no we're not skipping anything π
πΈ NAME πΈ
oo::abstract β a class that does not allow direct instances of itself π«Ά
β SYNOPSIS β
package require tcl::oo
oo::abstract method ?arg ...?
π¦ CLASS HIERARCHY π¦
like, the family tree. the ancestry. the bloodline π
oo::object
β oo::class
β oo::abstract
π DESCRIPTION π
so abstract classes are classes that can totally contain definitions, but you can't directly manufacture them, bestie β no cap. they're intended to only ever be inherited from and instantiated indirectly. it's giving "i don't do solo careers, i only do features" energy β¨
the characteristic methods of oo::class (create and new) are not exported by an instance of oo::abstract. so yeah, you can't just roll up and new one. that's the whole point π
ngl, a plot twist:oo::abstractis not itself an instance ofoo::abstract. iconic. the rule doesn't apply to the rule-maker π
π CONSTRUCTOR π
the oo::abstract class does not define an explicit constructor. which means it's effectively the same as the constructor of the oo::class class. lowkey just vibing with the default π
π§ DESTRUCTOR π§
the oo::abstract class does not define an explicit destructor either. destroying an instance of it is just like destroying an ordinary class β and heads up, it will destroy all its subclasses too. transitive destruction, periodt. the whole family goes down together π
π₯ EXPORTED METHODS π₯
the oo::abstract class defines no new exported methods. zero. none. empty list, main character energy π
π NON-EXPORTED METHODS π
the oo::abstract class explicitly states that create, createWithNamespace, and new are unexported. so they're right there in the forbidden section, iykyk π«
π EXAMPLES π
this example defines a simple class hierarchy and creates a new instance of it. then it invokes a method of the object before destroying the hierarchy and showing that the destruction is transitive. fr fr, watch:
oo::abstract create fruit {
method eat {} {
puts "yummy!"
}
}
oo::class create banana {
superclass fruit
method peel {} {
puts "skin now off"
}
}
set b [banana new]
$b peel β prints 'skin now off'
$b eat β prints 'yummy!'
set f [fruit new] β error 'unknown method "new"...'
so banana ate and slayed because it inherited from the abstract fruit π
but trying to new the abstract fruit directly? error. unknown method "new".... we love a boundary πΈ
π SEE ALSO π
oo::define(n)oo::object(n)
π KEYWORDS π
abstract class, class, metaclass, object
and that's the whole page, bestie π this one's TclOO version 0.3, page abstract(n) β go forth and inherit responsibly π§ββοΈβ¨
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- nixos 26.05: tcl 9.0.3
- Copyright (c) 2018 Donal K. Fellows
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms