lazyset(n)
π lazyset(n) β Lazy evaluation for variables and arrays
okay bestie, welcome to lazyset(n), the manual page for the lazyset package. it's giving "do it later but make it fashion" and honestly? iconic. β¨
β¨ NAME β¨
lazyset β Lazy evaluation π¦
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require lazyset ?1.1?
::lazyset::variable ?-array boolean? ?-appendArgs boolean? variableName
commandPrefix
π DESCRIPTION π
so the lazyset package hands you a whole mechanism for deferring execution of code until a specific variable β or literally any index of an array β gets referenced. like, the code just chills there. waiting. main character energy but off-screen until you call for it. π
π COMMANDS π
::lazyset::variable ?-array boolean? ?-appendArgs boolean? variableName commandPrefixβ this is the one and only, the moment, the whole vibe. it arranges for the code you pass ascommandPrefixto get executed the first time the variable named byvariableNameis read. π«Ά
now let's break down the options, because bestie, the details matter:
- if the optional argument
-array booleanis given as true, then the thing you named invariableNameis treated as an array, and attempting to read any index of that array causes that index to be set by thecommandPrefixas the indexes are read. one by one, as they're asked for. slay. β¨ - if the optional argument
-appendArgs booleanis given as false, then the variable name and subnames are not appended to thecommandPrefixbefore it gets evaluated. no extras, no add-ons, periodt. - if
-appendArgs booleanis not specified at all, or it's specified as true, then 1 or 2 additional arguments get appended to thecommandPrefix.- when
-array booleanis true: 2 arguments get appended, matching the name of the variable and the index. - otherwise: 1 argument gets appended, containing the name of the variable.
- when
and the tea β β the commandPrefix code runs in the same scope as the variable is read. same scope, no cap.
π§ EXAMPLES π§
here's the good stuff, copy-paste ready:
::lazyset::variable page {apply {{name} {
package require http
set token [http::geturl http://www.tcl.tk/]
set data [http::data $token]
return $data
}}}
puts $page
::lazyset::variable -array true page {apply {{name index} {
package require http
set token [http::geturl $index]
set data [http::data $token]
return $data
}}}
puts $page(http://www.tcl.tk/)
::lazyset::variable -appendArgs false simple {
return -level 0 42
}
puts $simple
see how $page just... doesn't do anything until you puts it? yeah. that's the whole point. ate. π
π AUTHORS π
Roy Keene π
π BUGS, IDEAS, FEEDBACK π
ngl, this document, and the package it describes, will undoubtedly contain bugs and other problems. it's not a vibe, it's just reality. so please report such things in the category utility of the Tcllib Trackers:
http://core.tcl.tk/tcllib/reportlist
and please also report any ideas for enhancements you may have for either the package and/or the documentation. we want all of it. π«Ά
when proposing code changes, please provide unified diffs, i.e. the output of diff -u.
also note β and this is important bestie β attachments are strongly preferred over inlined patches. you can attach stuff 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. iykyk. π
β CATEGORY β
Utility
π COPYRIGHT π
Copyright (c) 2018 Roy Keene
and that's the whole page, bestie!! this one came to you from tcllib, version 1.1, and the page itself is dated lazyset(n). go forth and defer some code. πβ¨ππ¦πΈπ«Ά
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- Copyright (c) 2018 Roy Keene
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms