1namespacex(n)             Namespace utility commands             namespacex(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       namespacex - Namespace utility commands
9

SYNOPSIS

11       package require Tcl  8.5
12
13       package require namespacex  ?0.2?
14
15       ::namespacex hook add ?namespace? cmdprefix
16
17       ::namespacex hook proc ?namespace? arguments body
18
19       ::namespacex hook on ?namespace? guardcmdprefix actioncmdprefix
20
21       ::namespacex hook next arg...
22
23       ::namespacex import fromns cmdname ?newname ...?
24
25       ::namespacex info allchildren namespace
26
27       ::namespacex info allvars namespace
28
29       ::namespacex normalize namespace
30
31       ::namespacex info vars namespace ?pattern?
32
33       ::namespacex state get namespace
34
35       ::namespacex state set namespace dict
36
37       ::namespacex state drop namespace
38
39       ::namespacex strip prefix namespaces
40
41______________________________________________________________________________
42

DESCRIPTION

44       This  package  provides  a  number of utility commands for working with
45       namespaces.  The commands fall into four categories:
46
47       [1]    Hook commands provide and manipulate a chain of  commands  which
48              replaces the single regular namespace unknown handler.
49
50       [2]    An  import  command  provides  the ability to import any command
51              from another namespace.
52
53       [3]    Information commands allow querying of variables and child name‐
54              spaces.
55
56       [4]    State commands provide a means to serialize variable values in a
57              namespace.
58

COMMANDS

60       ::namespacex hook add ?namespace? cmdprefix
61              Adds the cmdprefix to the chain of unknown command handlers that
62              are  invoked  when  the namespace would otherwise invoke its un‐
63              known handler.  If namespace is not specified, then cmdprefix is
64              added to the chain of handlers for the namespace of the caller.
65
66              The  chain  of  cmdprefix are executed in reverse order of addi‐
67              tion, i.e. the most recently added cmdprefix is executed  first.
68              When executed, cmdprefix has additional arguments appended to it
69              as would any namespace unknown handler.
70
71       ::namespacex hook proc ?namespace? arguments body
72              Adds an anonymous procedure to the chain  of  namespace  unknown
73              handlers for the namespace.
74
75              If  namespace is not specified, then the handler is added to the
76              chain of handlers for the namespace of the caller.
77
78              The arguments and body are specified as for the core  proc  com‐
79              mand.
80
81       ::namespacex hook on ?namespace? guardcmdprefix actioncmdprefix
82              Adds a guarded action to the chain of namespace unknown handlers
83              for the namespace.
84
85              If namespace is not specified, then the handler is added to  the
86              chain of handlers for the namespace of the caller.
87
88              The guardcmdprefix is executed first. If it returns a value that
89              can be interpreted as false, then the next unknown hander in the
90              chain  is  executed.  Otherwise, actioncmdprefix is executed and
91              the return value of the handler is the value returned by action‐
92              cmdprefix.
93
94              When  executed, both guardcmdprefix and actioncmdprefix have the
95              same additional arguments appended as for any namespace  unknown
96              handler.
97
98       ::namespacex hook next arg...
99              This command is available to namespace hooks to execute the next
100              hook in the chain of handlers for the namespace.
101
102       ::namespacex import fromns cmdname ?newname ...?
103              Imports the command cmdname from the fromns namespace  into  the
104              namespace  of  the caller.  The cmdname command is imported even
105              if the fromns did not originally export the command.
106
107              If newname is specified, then the imported command will be known
108              by that name. Otherwise, the command retains is original name as
109              given by cmdname.
110
111              Additional pairs of cmdname /  newname  arguments  may  also  be
112              specified.
113
114       ::namespacex info allchildren namespace
115              Returns  a  list containing the names of all child namespaces in
116              the specified namespace and its  children.  The  names  are  all
117              fully qualified.
118
119       ::namespacex info allvars namespace
120              Returns  a  list  containing  the  names of all variables in the
121              specified namespace and its children. The names  are  all  given
122              relative to namespace, and not fully qualified.
123
124       ::namespacex normalize namespace
125              Returns  the absolute name of namespace, which is resolved rela‐
126              tive to the namespace of the caller,  with  all  unneeded  colon
127              characters removed.
128
129       ::namespacex info vars namespace ?pattern?
130              Returns  a  list  containing  the  names of all variables in the
131              specified namespace.  If the pattern argument is specified, then
132              only variables matching pattern are returned. Matching is deter‐
133              mined using the same rules as for string match.
134
135       ::namespacex state get namespace
136              Returns a dictionary holding the names and values of  all  vari‐
137              ables in the specified namespace and its child namespaces.
138
139              Note that the names are all relative to namespace, and not fully
140              qualified.
141
142       ::namespacex state set namespace dict
143              Takes a dictionary holding the names and values  for  a  set  of
144              variables  and replaces the current state of the specified name‐
145              space and its child namespaces with this state.  The  result  of
146              the command is the empty string.
147
148       ::namespacex state drop namespace
149              Unsets  all  variables  in the specified namespace and its child
150              namespaces.  The result of the command is the empty string.
151
152       ::namespacex strip prefix namespaces
153              Each item in namespaces must be the absolute normalized name  of
154              a  child namespace of namespace prefix.  Returns the correspond‐
155              ing list of relative names of child namespaces.
156

BUGS, IDEAS, FEEDBACK

158       This document, and the package it describes, will  undoubtedly  contain
159       bugs and other problems.  Please report such in the category namespacex
160       of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist].   Please
161       also  report any ideas for enhancements you may have for either package
162       and/or documentation.
163
164       When proposing code changes, please provide unified diffs, i.e the out‐
165       put of diff -u.
166
167       Note  further  that  attachments  are  strongly  preferred over inlined
168       patches. Attachments can be made by going  to  the  Edit  form  of  the
169       ticket  immediately  after  its  creation, and then using the left-most
170       button in the secondary navigation bar.
171

KEYWORDS

173       extended namespace, info, namespace unknown, namespace utilities, state
174       (de)serialization, unknown hooking, utilities
175
177       Copyright (c) 200? Neil Madden (http://wiki.tcl.tk/12790)
178       Copyright (c) 200? Various (http://wiki.tcl.tk/1489)
179       Copyright (c) 2010 Documentation, Andreas Kupries
180
181
182
183
184tcllib                                0.2                        namespacex(n)
Impressum