Tcl_FindCommand: bogus comment?
Closed / Fixed1114355fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 19 years ago
Descriptionplain2005-02-01 23:22:13
A comment following the "name" argument to Tcl_FindCommand claims: "If it starts with "::", will be looked up in global namespace." Since custom resolvers are given first crack at the resolving task, and since they are apparently free to resolve names matching ::* however they like, I think this comment is false.
dgpplain2005-02-02 06:26:44
Logged In: YES user_id=80530 Completing the thought, if a Tcl_FindCommand() caller wants to force resolution in the global namespace, it should use the TCL_GLOBAL_ONLY flag to accomplish that.
dgpplain2005-02-02 23:18:25
Logged In: YES user_id=80530 there may be a lurking inconsistency here with Tcl_GetCommandFromObj() where commands beginning with "::" *do* get special treatment.
dgpplain2005-02-02 23:30:58
Logged In: YES user_id=80530 ok, so I'm closing in on the opinion that the comment *ought* to be true, and the bug here is that the current implementation of Tcl_FindCommand allows custom resolvers to interpret a fully qualified command name to mean something other than its plain meaning. It appears this possibility is inconsistent with assumptions in other parts of Tcl.
dgp Ticket [1114355fff]: 1 change
[History diff]2005-08-30 02:01:27
msofer Ticket [1114355fff]: 2 changes
[History diff]2007-09-13 07:41:42
msoferplain2007-10-28 01:03:21
Logged In: YES user_id=148712 Originator: NO No inconsistency there: SetCmdNameFromAny calls Tcl_FindCommand to determine the command. What may be problematic is that the cmdName stores the global ns as the origin of the search for FQ names. This would cause buggy behaviour if (a) a namespace ns has a resolver that redirects FQ names (b) an FQ command ::cmdA is searched starting from ns, and resolved to (say) ::B (c) ::cmdA is resolved starting from elsewhere; the cached pointer to ::B will be used I agree that eventually the "correct" behaviour may be for FQ names to bypass all resolvers. Chose a "conservative" fix for now: insure that Tcl_FindCommand starts the search for FQ commands in the global ns. The difference is that resolvers on the global namespace or interp wide resolvers will be called. Tests show that itcl, xotcl and TclOO do not mind.
Log in (anonymous is fine) to add a comment.