init stubs from PkgRequire, not interp
Closed / Fixed540378ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 17 years ago
Descriptionplain2002-04-06 23:45:57
>From "Paul Duffin" <[email protected]> One thing that you can do in the meantime is make a slight modification to the Tcl_InitStubs function in tclStubLib.c which will allow you a lot of flexibility in how you do this. As you know Tcl_InitStubs initialises the global pointer tclStubPtr so that it points to Tcl's stub table. At the moment it uses the stub table pointer which is stored in the Interp structure, this should be changed to use the stub table pointer which is returned from Tcl_PkgRequireEx instead. This minor and totally compatible change needs to be done immediately as the Tcl_InitStubs function is embedded inside extensions so extensions will need to be rebuilt for the change to take effect. The benefit of doing this is that it would be possible to have multiple versions of the Tcl stub table in use at the same time, you could have an 8.1 version (because 8.0 does not have a stub table, :-( ), a 9.0 version and a 10.0 version all at the same time. The only restriction on the table structure is that those functions which are used by Tcl_InitStubs (Tcl_PkgRequireEx) need to be in the same place in all the structures. You can totally restructure the rest of the table(s) to suit your needs. The backward compatible stub tables can be provided by dynamically loadable extensions. To enable this would obviously need some modifications to the package mechanism as it stands to allow multiple versions of a package to be loaded at one time, or at least allow compatability versions of a package to be loaded as well as the current version. These issues can be resolved at your leisure but the change to Tcl_InitStubs (and all the other _InitStubs functions) needs to be done now, otherwise you will not have the choice. Instead of char * Tcl_InitStubs (interp, version, exact) Tcl_Interp *interp; char *version; int exact; { char *actualVersion; TclStubs *tmp; if (!tclStubsPtr) { tclStubsPtr = HasStubSupport(interp); if (!tclStubsPtr) { return NULL; } } actualVersion = Tcl_PkgRequireEx(interp, "Tcl", version, exact, (ClientData *) &tmp); if (actualVersion == NULL) { tclStubsPtr = NULL; return NULL; } if (tclStubsPtr->hooks) { tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs; tclIntStubsPtr = tclStubsPtr->hooks->tclIntStubs; tclIntPlatStubsPtr = tclStubsPtr->hooks->tclIntPlatStubs; } else { tclPlatStubsPtr = NULL; tclIntStubsPtr = NULL; tclIntPlatStubsPtr = NULL; } return actualVersion; } you need char * Tcl_InitStubs (interp, version, exact) Tcl_Interp *interp; char *version; int exact; { char *actualVersion; if (!tclStubsPtr) { tclStubsPtr = HasStubSupport(interp); if (!tclStubsPtr) { return NULL; } } actualVersion = Tcl_PkgRequireEx(interp, "Tcl", version, exact, (ClientData *) &tclStubsPtr); if (actualVersion == NULL) { tclStubsPtr = NULL; return NULL; } if (tclStubsPtr->hooks) { tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs; tclIntStubsPtr = tclStubsPtr->hooks->tclIntStubs; tclIntPlatStubsPtr = tclStubsPtr->hooks->tclIntPlatStubs; } else { tclPlatStubsPtr = NULL; tclIntStubsPtr = NULL; tclIntPlatStubsPtr = NULL; } return actualVersion; }
dgpplain2007-10-24 22:48:44
Logged In: YES user_id=80530 Originator: YES jenglish, it appears that your 2005-11-20 commit to tclStubLib.c had the effect of satisfying this Feature Request. Can you confirm? That would indicate this feature is available in all stable Tcl releases 8.4.12 or later.
jenglishplain2007-11-12 13:47:38
Logged In: YES user_id=68433 Originator: NO Confirmed.
jenglishplain2010-04-03 05:24:22
Since this has recently come up again, I hasten to add: this is Not A Good Idea. Explicitly: the meat of the original FR is: | The benefit of doing this is that it would be possible to have multiple versions | of the Tcl stub table in use at the same time. This Is Not A Good Idea. Just because we *can* do something doesn't mean we *should*. There is no "benefit" to having multiple versions of the Tcl stub table available in a single process. In fact I'd go so far as to say that anybody who seriously wants this purportedly proposed misfeature is just begging to be thrown into the bottom of the pit of what is affectionately known as "DLL Hell" for the sole purpose of digging themselves a brand new, deeper and more painful level. That would be a Bad Idea.
Log in (anonymous is fine) to add a comment.