From: Donald G P. <don...@ni...> - 2025-05-19 11:58:13
|
Revising the behavior of an existing subcommand raises worries ( at least ) about compatibility. Consider proposing a new subcommand instead. On 5/19/25 01:40, Christian Werner wrote: > Hello all, > > (posted again in case I've sent it with the wrong account) > > please could some tip fossil maintainer add the following tip. > > ---8><---8><--- > > # TIP 722 Improve **package present** subcommand > Author: Christian Werner <und...@gm...> > State: Draft > Type: Project > Created: 19-May-2025 > Keywords: Tcl,package > ----- > > # Abstract > > This TIP proposes to improve the **package present** subcommand such > that it can be used to return a list of all currently loaded packages. > > # Rationale > > Although there is a **package names** subcommand which returns a list of > all currently available packages there's no equivalent to retrieve the > list of currently loaded packages. However, the latter can be of use > e.g. to build a software bill of materials of an application or to help > in generating a package dependency graph. > > # Specification > > For **package present** without any further arguments (which currently > generates an error message) the implementation of **package names** is > borrowed but its selection clause while iterating over the package hash > table is changed to add package names to the result list for which a > version is known (which means that the package has been loaded). > > ** Implementation > > The code block to add to the current **package present** implementation is: > > ''' > if (objc < 3) { > Tcl_Obj *resultObj; > > TclNewObj(resultObj); > tablePtr = &iPtr->packageTable; > for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); hPtr != NULL; > hPtr = Tcl_NextHashEntry(&search)) { > pkgPtr = Tcl_GetHashValue(hPtr); > if (pkgPtr->version != NULL) { > Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( > Tcl_GetHashKey(tablePtr, hPtr), -1)); > } > } > Tcl_SetObjResult(interp, resultObj); > break; > } > ''' > > The test code in ```package.test``` must be changed for test case 8.11 to: > > ``` > test package-8.11 {Tcl_PackageCmd procedure, "present" option} -body { > package present > } -match glob -result * > ``` > > # Copyright > > This document has been placed in the public domain. > > ---8><---8><--- > > Thank you, > Christian > > > > _______________________________________________ > Tcl-Core mailing list > Tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-core -- | Don Porter Applied and Computational Mathematics Division | | don...@ni... Information Technology Laboratory | | http://math.nist.gov/~DPorter/ NIST | |______________________________________________________________________| |