Tcl_PackageInitProc could accept some user data
Open2017905fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-07-14 11:42:13
I've come to think that the handler
typedef int Tcl_PackageInitProc(
Tcl_Interp *interp);
which is passed to :
Tcl_StaticPackage(interp,
pkgName,
initProc,
safeInitProc)
would benefit accepting some user data.
I hence suggest to change add an API to Tcl_StaticPackage and its package-init handler :
hence change its API to :
Tcl_StaticPackage(interp,
pkgName,
initProc,
safeInitProc,
ClientData clientData)
and :
typedef int Tcl_PackageInitProc(
Tcl_Interp *interp,
ClientData clientData);
At least, this would have been usefull to me, since my package's commands use a specific client data.
With the current API, I need to do some "equilibrist work" to retrieve the CLientData I pass to Tcl_CreateCommand.
Hope this helps !
Nicolas
PS : I may be wrong in the "Category". Sorry in this case.
nicolascastagneplain2008-07-14 21:20:27
Logged In: YES user_id=1258423 Originator: YES Indeed, I've been told that the use of : Tcl_SetAssocData(interp, key, ClientData) Tcl_GetAssocData(interp, key) allow retrieving ClientData from within Tcl_PackageInitProc callback of Tcl_StaticPackage. However, I still think adding a ClientData to the Tcl_PackageInitProc would be useful for static packages. Or adding a note on "Tcl_SetAssocData" in the documentation of Tcl_StaticPackage would be OK and pbly sufficient.
dgpplain2008-07-14 22:13:34
Logged In: YES user_id=80530 Originator: NO Note that the Tcl_PackageInitProc is the typedef for the callback used to initialize all extensions. Any change to that is going to impact every extension in a radical way. I think we need a really compelling justification as well as a major release of Tcl to imagine doing that. For now, Tcl_SetAssocData() seems to offer a 'workaround' for the use case in mind, so dropping priority on this.
dgp Ticket [2017905fff]: 1 change
[History diff]2008-07-14 22:13:55
Log in (anonymous is fine) to add a comment.