abstract(3tcl)

πŸ“¦
version 9.0.4 Β· 3 versions
, in ubuntu stonking

✨ 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::abstract is not itself an instance of oo::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? fruit said "not today." fruit is abstract, so [fruit new] does not work β€” you get error '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