oometa(3tcl)
β¨ NAME β¨
okay so bestie, meet oometa π β it's the oo::meta data registry for classess. (yes. "classess". that's literally what it says, we are NOT fixing it, we respect the source π
)
π SYNOPSIS π
oo::meta::info
oo::meta::info branchget ?key? ?...?
oo::meta::info branchset ?key...? key value
oo::meta::info dump class
oo::meta::info class is type ?args?
oo::meta::info class merge ?dict? ?dict? ?...?
oo::meta::info class rebuild
oo::meta::metadata class
oo::define meta
oo::class method meta
oo::object method meta
oo::object method meta cget ?field? ?...? field
π DESCRIPTION π
The oo::meta package provides a data registry service for TclOO classes. that's the whole vibe, and honestly? it eats. π
πΈ USAGE πΈ
here's the whole glow-up in action, no cap:
oo::class create animal {
meta set biodata animal: 1
}
oo::class create mammal {
superclass animal
meta set biodata mammal: 1
}
oo::class create cat {
superclass mammal
meta set biodata diet: carnivore
}
cat create felix
puts [felix meta dump biodata]
> animal: 1 mammal: 1 diet: carnivore
felix meta set biodata likes: {birds mice}
puts [felix meta get biodata]
> animal: 1 mammal: 1 diet: carnivore likes: {bird mice}
# Modify a class
mammal meta set biodata metabolism: warm-blooded
puts [felix meta get biodata]
> animal: 1 mammal: 1 metabolism: warm-blooded diet: carnivore likes: {birds mice}
# Overwrite class info
felix meta set biodata mammal: yes
puts [felix meta get biodata]
> animal: 1 mammal: yes metabolism: warm-blooded diet: carnivore likes: {birds mice}
look at felix inheriting his whole ancestry and then overwriting it. main character energy fr fr π±π
π¦ CONCEPT π¦
The concept behind oo::meta is that each class contributes a snippet of local data. When oo::meta::metadata is called, the system walks through the linear ancestry produced by oo::meta::ancestors, and recursively combines all of that local data for all of a class' ancestors into a single dict. Instances of oo::object can also combine class data with a local dict stored in the meta variable.
so yeah, it's giving family tree but make it data. π
π COMMANDS π
oo::meta::info
oo::meta::info is intended to work on the metadata of a class in a manner similar to if the aggregate pieces where assembled into a single dict. The system mimics all of the standard dict commands, and addes the following:
oo::meta::info branchget ?key? ?...?
Returns a dict representation of the element at args, but with any trailing : removed from field names. π
::oo::meta::info $myclass set option color {default: green widget: colorselect}
puts [::oo::meta::info $myclass get option color]
> {default: green widget: color}
puts [::oo::meta::info $myclass branchget option color]
> {default green widget color}
oo::meta::info branchset ?key...? key value
Merges dict with any other information contaned at node ?key...?, and adding a trailing : to all field names.
::oo::meta::info $myclass branchset option color {default green widget colorselect}
puts [::oo::meta::info $myclass get option color]
> {default: green widget: color}
oo::meta::info dump class
Returns the complete snapshot of a class metadata, as producted by oo::meta::metadata. πΈ
oo::meta::info class is type ?args?
Returns a boolean true or false if the element ?args? would match string is type value
::oo::meta::info $myclass set constant mammal 1
puts [::oo::meta::info $myclass is true constant mammal]
> 1
oo::meta::info class merge ?dict? ?dict? ?...?
Combines all of the arguments into a single dict, which is then stored as the new local representation for this class.
oo::meta::info class rebuild
Forces the meta system to destroy any cached representation of a class' metadata before the next access to oo::meta::metadata. cache? cleared. we don't know her anymore π
oo::meta::metadata class
Returns an aggregate picture of the metadata for class, combining its local data with the local data from its ancestors.
oo::define meta
The package injects a command oo::define::meta which works to provide a class in the process of definition access to oo::meta::info, but without having to look the name up.
oo::define myclass {
meta set foo bar: baz
}
oo::class method meta
The package injects a new method meta into oo::class which works to provide a class instance access to oo::meta::info.
oo::object method meta
The package injects a new method meta into oo::object. oo::object combines the data for its class (as provided by oo::meta::metadata), with a local variable meta to produce a local picture of metadata. This method provides the following additional commands:
oo::object method meta cget ?field? ?...? field
Attempts to locate a singlar leaf, and return its value. For single option lookups, this is faster than my meta getnull ?field? ?...? field], because it performs a search instead directly instead of producing the recursive merge product between the class metadata, the local meta variable, and THEN performing the search.
ngl this one is the speedrun strat for single lookups. the long way builds the WHOLE merged thing first and then searches. π
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category tcloo of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.
seriously bestie, attach the file. do not paste the patch into the ticket. i am begging π«Ά
β KEYWORDS β
TOOL, TclOO
π CATEGORY π
TclOO
π COPYRIGHT π
Copyright (c) 2015 Sean Woods <yoda@etoyoc.com>
and that's the whole page, bestie π this one shipped with tcllib 0.7.2 and lives as oometa(3tcl) in the TclOO category β go forth and registry your data, slay β¨π§
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- Copyright (c) 2015 Sean Woods <yoda@etoyoc\&.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms