TIP 277: create namespaces as needed
Open582926ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 20 years ago
Descriptionplain2002-07-17 16:48:21
[upvar $level $otherVar $myVar] is supposed to be able to handle a non-existent $otherVar, and mostly it does. But... % upvar 0 foo::bar soom can't access "foo::bar": parent namespace doesn't exist That seems counter to the spirit of [upvar] being able to link to non-existent variables. Seems similar to other situations where one would think that namespaces would be created as needed.
msoferplain2002-07-18 20:44:06
Logged In: YES user_id=148712 This looks OK to me, it is perfectly consistent with % set foo::bar soom can't set "foo::bar": parent namespace doesn't exist If this is the desired behaviour is an entirely different matter ;)
dgpplain2002-07-18 21:38:25
Logged In: YES user_id=80530 Fair enough. This is really an FR then. Is there already an FR filed asking that namespaces get created as needed?
msoferplain2002-07-19 02:41:54
Logged In: YES user_id=148712 I couldn't find any.
dgpplain2002-07-19 03:07:56
Logged In: YES user_id=80530 more generally then, consider this a request that whenever a "namespace does not exist" error message is currently being returned, instead have the required namespace created automatically, just as variables are created as needed without any prior "declaration".
msoferplain2003-08-10 21:40:57
Logged In: YES
user_id=148712
Another example reported by Michael Kirkham <muonics> in
[Bug 786187]:
% namespace children ::
::tcl
% proc ns::test {} {}
can't create procedure "ns::test": unknown namespace
% proc test {} {}
% rename test ns::test
% namespace children ::
::ns ::tcl
msoferplain2003-08-10 21:43:44
Logged In: YES user_id=148712 The docs do not really talk about the issue. However, this being very longstanding behaviour (since 8.0) I'm hesitant to fix it within a minor release. Maybe it should be TIPped? For the record, my (non-voting) opinion on such a TIP would be YES.
dgpplain2003-08-11 00:06:53
Logged In: YES user_id=80530 No doubt a TIP is needed; that's why it's a feature request. The only argument against it, I think, is that the error behavior currently implemented makes it easier to discover bugs created by typos in namespace names.
jenglishplain2003-10-07 04:36:31
Logged In: YES user_id=68433 If $otherVar refers to a nonexistent namespace "foo", should "foo" be created as a subnamespace of the current namespace, or of the root? Either way, it could lead to more subtle problems like the "creative writing" dilemma.
dgpplain2003-10-07 04:37:32
Logged In: YES user_id=80530 Note that this misfeature contributes to Tk Bug 793909. It is likely there are several similar bugs in Tk, and perhaps in other extensions originally written for Tcl 7 that assume that Tcl_SetVar() will always succeed in creating a variable, and Tcl_TraceVar() will always succeed in creating a variable trace.
msofer Ticket [582926ffff]: 1 change
[History diff]2006-09-30 00:45:07
dgp Ticket [582926ffff]: 1 change
[History diff]2006-11-23 03:22:55
dgp Ticket [582926ffff]: 1 change
[History diff]2007-01-30 00:27:23
Log in (anonymous is fine) to add a comment.