TIP 277: Create Namespaces as Needed

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Author:		Miguel Sofer <msofer@users.sourceforge.net>
State:		Draft
Type:		Project
Tcl-Version:	8.7
Vote:		Pending
Created:	01-Oct-2006
Post-History:	

Abstract

This TIP proposes that namespaces be created automatically whenever a script tries to create a command, variable or child namespace in it.

Proposal

As proposed in [FR 582926], whenever a script tries to create a command, variable or namespace, Tcl should automatically create all namespaces in the path if they do not already exist.

In other words, as an example, the current behaviour

   % namespace children [namespace current]
   ::activestate ::tcl
   % set a::b::x 2
   can't set "a::b::x": parent namespace doesn't exist
   % namespace children [namespace current]
   ::activestate ::tcl

should become

   % namespace children [namespace current]
   ::activestate ::tcl
   % set a::b::x 2
   2
   % namespace children [namespace current]
   ::a ::activestate ::tcl
   % namespace children ::a
   ::a::b

Reference Implementation and Documentation

Forthcoming at SF.

Copyright

This document has been placed in the public domain.

History