abstract(3tcl)
β¨ abstract β the class that says "you can't sit with us" β¨
okay bestie, this is abstract from the TclOO manual pages, aka abstract(3tcl), filed under TclOO Commands, and honestly? it's giving gatekeeper in the best way π
πΈ NAME πΈ
oo::abstract β a class that does not allow direct instances of itself
like... she's a class, but you literally cannot make her. she exists to be inherited from. main character energy, unfollowed by everyone. π
π SYNOPSIS π
package require tcl::oo
oo::abstract method ?arg ...?
π¦ CLASS HIERARCHY π¦
oo::object
β oo::class
β oo::abstract
so she's a grandbaby of oo::object, a direct child of oo::class, and the final boss of "no, you can't instantiate me." π
π DESCRIPTION π
Abstract classes are classes that can contain definitions, but which cannot be directly manufactured. no cap. they are intended to only ever be inherited from and instantiated indirectly β like, you don't wear the pattern, you wear the pieces cut from it. π§΅
The characteristic methods of oo::class β create and new β are not exported by an instance of oo::abstract. so those two little stars of the show? not available. locked in the vault. π
heads up bestie:oo::abstractis not itself an instance ofoo::abstract. yes, that's a real sentence, and yes, it's iconic. π
π§ CONSTRUCTOR
The oo::abstract class does not define an explicit constructor β which basically means it is effectively the same as the constructor of the oo::class class. she inherited it and did not customize it. lowkey efficient. π
π 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 yes, that will destroy all its subclasses. the whole family tree goes down together. dramatic? maybe. but that's the vibe. ππ«Ά
π EXPORTED METHODS
The oo::abstract class defines no new exported methods. none. zero. the list is empty and honestly? she's thriving. β¨
π NON-EXPORTED METHODS
The oo::abstract class explicitly states that create, createWithNamespace, and new are unexported. periodt. π
β EXAMPLES β
This example defines a simple class hierarchy and creates a new instance of it. It then invokes a method of the object before destroying the hierarchy and showing that the destruction is transitive. watch and learn, bestie β it's a whole story arc. π
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"...'
see that last line?fruitsaid "not today."fruitis abstract, so[fruit new]does not work β you geterror 'unknown method "new"...'. she's a class about the idea of fruit, not the actual snack. π
π₯ SEE ALSO π₯
oo::define(3tcl)oo::object(3tcl)
π KEYWORDS π
abstract class, class, metaclass, object
okay that's the whole page, bestie, you ate it π«Ά this was TclOO version 0.3, from the abstract(3tcl) page β mwah, go make something abstract and unrepeatable πβ¨π
π¦ where this page comes from
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 2018 Donal K. Fellows
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms