component(n)

✨ component(n) β€” the itcl::component glow-up ✨

okay bestie, so this is the component(n) page from [incr Tcl] β€” yeah, manual name itcl, section n, she's a Tcl thing πŸ’… β€” and we're about to make components make sense, fr fr.


🌸 NAME 🌸

itcl::component β€” define components for extendedclass, widget or widgetadaptor

ngl, some parts of this description are literally "borrowed" from the Tcl extension [snit], because the functionality is mostly identical. we're giving credit where credit is due 🫢


πŸ’€ WARNING! πŸ’€

This is new functionality in [incr Tcl] where the API can still change!!

not me warning you that the API is still in her experimental era 😭 things can shift under you, so stay alert bestie.


✨ SYNOPSIS ✨

public component comp ?-inherit?
protected component comp ?-inherit?
private component comp ?-inherit?

three access levels, one iconic little command. pick your vibe πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so the component command is what you use inside an [incr Tcl] extendedclass/widget/widgetadaptor definition to define components. it's an inside-job situation, she does not work out in the open.

it explicitly declares a component called comp, and β€” the part that's lowkey magic β€” it automatically defines the component's instance variable. no extra work, she just appears. main character energy tbh ⭐

if you pass the -inherit option, then all unknown methods and options get delegated to this component. and the way the name reads, -inherit is implying that instances of this new type inherit, in a sense, the methods and options of the component. like she's passing down the family recipes πŸ“

so basically, -inherit yes is equivalent to:

component mycomp
delegate option * to mycomp
delegate method * to mycomp

same energy, fewer lines. slay ✨


πŸ”₯ KEYWORDS πŸ”₯

component, widget, widgetadaptor, extendedclass


and that's the whole page, bestie β€” no cap πŸ’– this was component(n) from itcl version 4.0, dated... well, the footer says component(n) right back at you, so consider yourself fully informed. go forth and delegate πŸŒˆπŸ¦‹πŸ’