lazyset(3tcl) | Lazy evaluation for variables and arrays | lazyset(3tcl) |
lazyset - Lazy evaluation
package require Tcl 8.5
package require lazyset ?1?
::lazyset::variable ?-array boolean? ?-appendArgs boolean? variableName commandPrefix
The lazyset package provides a mechanism for deferring execution of code until a specific variable or any index of an array is referenced.
::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
Roy Keene
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category utility 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.
Utility
Copyright (c) 2018 Roy Keene
1 | tcllib |