Tcl_PkgRequire(3tcl)
π Tcl_PkgRequire β the package version control page (from the Tcl Library Procedures, bestie) π
okay so welcome to Tcl_PkgRequire(3tcl), which is the manual page all about package version control at the C level. no cap, this is the one that lets your C code do the same little dance that package require does in Tcl script land. let's get into it π«Ά
β¨ NAME β¨
Tcl_PkgRequire, Tcl_PkgRequireEx, Tcl_PkgRequireProc, Tcl_PkgPresent, Tcl_PkgPresentEx, Tcl_PkgProvide, Tcl_PkgProvideEx β package version control, literally the whole squad π
πΈ SYNOPSIS πΈ
#include <tcl.h>
const char *
Tcl_PkgRequire(interp, name, version, exact)
const char *
Tcl_PkgRequireEx(interp, name, version, exact, clientDataPtr)
int
Tcl_PkgRequireProc(interp, name, objc, objv, clientDataPtr)
const char *
Tcl_PkgPresent(interp, name, version, exact)
const char *
Tcl_PkgPresentEx(interp, name, version, exact, clientDataPtr)
int
Tcl_PkgProvide(interp, name, version)
int
Tcl_PkgProvideEx(interp, name, version, clientData)
π ARGUMENTS π
Tcl_Interp *interp(in) β the interpreter where the package is needed or available. it's giving the main character, everything happens in here.const char *name(in) β name of the package. just the name, bestie.const char *version(in) β a version specification string, described the same way as forpackage require.int exact(in) β non-zero means only the exact version you named inversionis acceptable, periodt. zero means newer versions thanversionare also fine, as long as they've got the same major version number asversion.const void *clientData(in) β an arbitrary value you wanna associate with the package. like a lil personality trait for it πvoid *clientDataPtr(out) β pointer to a place to store the value associated with the matching package. important: it's only changed if the pointer isn'tNULLand the function completed successfully. also the storage can be any pointer type that's the same size as a void pointer.Tcl_Size objc(in) β number of requirements.Tcl_Obj* objv[](in) β array of requirements. a whole lineup β¨
π DESCRIPTION π
These procedures are the C-level interfaces to Tcl's package and version management facilities. iykyk.
So like, mapping time:
Tcl_PkgRequireis equivalent to thepackage requirecommand.Tcl_PkgPresentis equivalent to thepackage presentcommand.Tcl_PkgProvideis equivalent to thepackage providecommand.
For the deets on what these procedures actually do, go read the documentation for those Tcl commands. this page is the vibes, that page is the lore.
If Tcl_PkgPresent or Tcl_PkgRequire complete successfully, they return a pointer to the version string for the version of the package that is provided in the interpreter β and lowkey note that this may be different than version. if an error occurs, they return NULL and leave an error message in the interpreter's result. π
Tcl_PkgProvide returns TCL_OK if it completes successfully; if an error occurs it returns TCL_ERROR and leaves an error message in the interpreter's result.
Tcl_PkgProvideEx, Tcl_PkgPresentEx and Tcl_PkgRequireEx are the ones that let you set and retrieve the client data associated with the package. in all other respects they are equivalent to the matching functions. so same energy, just with a lil extra π
Tcl_PkgRequireProc is the form of package require that handles multiple requirements. the other forms are just there for backward compatibility and they translate their invocations into this form. iconic behavior honestly.
π REFERENCE COUNT MANAGEMENT π
heads up, bestie, this one's important!
The requirements values given (in the objv argument) to Tcl_PkgRequireProc must have non-zero reference counts. non-zero. not zero. fr fr, don't skip this one.
β KEYWORDS β
package, present, provide, require, version
π¦ SEE ALSO π¦
and that's the whole page, bestie, you ate it π
β¨ this was Tcl version 7.5, page Tcl_PkgRequire(3tcl), and if you read all the way down here then you're genuinely the main character. go require a package, slay, no cap πππΈπ«Ά
π¦ where this page comes from
- debian trixie: tcl9.0-doc 9.0.1+dfsg-2
- ubuntu questing: tcl9.0-doc 9.0.2+dfsg-1
- ubuntu resolute: tcl9.0-doc 9.0.3+dfsg-1
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms