Artifact dd7512223a30c489141b0c9443e40daf7d3b6169240095d070150a473fb55d89:
- File doc/markdown/Tcl/abstract.md — part of check-in [b84ce0eee1] at 2026-10-04 22:10:02 on branch tip-700 — file location re-organisation (part 1) (user: Torsten, size: 2152) [annotate] [blame] [check-ins using]
- File doc/markdown/abstract.md — part of check-in [5e80e55e41] at 2026-09-26 22:40:07 on branch tip-700 — - added a "title" metadata element to the generated yaml block to satisfy Pandoc when converting to HTML - added markdown2html.tcl as prototype/placeholder of conversion script markdown -> HTML - added some CSS to play with a good visual representation of the generated HTML, starting with the n section pages - fixed man2markdown.tcl not giving the two .TP/.IP parsing places the same treatment (user: Torsten, size: 2152) [annotate] [blame] [check-ins using]
CommandName: abstract title: abstract ManualSection: n Version: 0.3 TclPart: TclOO TclDescription: TclOO Commands Links:
- oo::define(n)
- oo::object(n) Keywords:
- abstract class
- class
- metaclass
- object Copyright:
- Copyright (c) 2018 Donal K. Fellows ---
Name
oo::abstract - A class that does not allow direct instances of itself
Synopsis
::: {.synopsis} ::: [package]{.cmd} [require]{.sub} [tcl::oo]{.lit}
[oo::abstract]{.cmd} [method]{.arg} [arg]{.optdot} :::
Class hierarchy
::: {.classhierarchy} :::
oo::object
→ oo::class
→ oo::abstract
:::
Description
Abstract classes are classes that can contain definitions, but which cannot be directly manufactured; they are intended to only ever be inherited from and instantiated indirectly. The characteristic methods of oo::class (create and new) are not exported by an instance of oo::abstract.
Note that oo::abstract is not itself an instance of oo::abstract.
Constructor
The oo::abstract class does not define an explicit constructor; this means that it is effectively the same as the constructor of the oo::class class.
Destructor
The oo::abstract class does not define an explicit destructor; destroying an instance of it is just like destroying an ordinary class (and will destroy all its subclasses).
Exported methods
The oo::abstract class defines no new exported methods.
Non-exported methods
The oo::abstract class explicitly states that create, createWithNamespace, and new are unexported.
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.
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"...'