TIP #277: Create Namespaces as Needed


TIP:277
Title:Create Namespaces as Needed
Version:$Revision: 1.3 $
Author:Miguel Sofer <msofer at users dot sourceforge dot net>
State:Draft
Type:Project
Tcl-Version:8.7
Vote:Pending
Created:Sunday, 01 October 2006

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.


Powered by Tcl[Index] [History] [Edit] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]

TIP AutoGenerator - written by Donal K. Fellows