'''namespace current''' Returns the fully-qualified name for the current namespace. The actual name of the global namespace is "" (i.e., an empty string), but this command returns '''::''' for the global namespace as a convenience to programmers. ---- [Jasp] The so called convenience of returning ''::'' has actually become an annoyance for me. The following code is supposted to take the argument variable ''database'', containing a procedure name, and get it's full path (prepend command works like append, except inserts the concentration of arguments at start of variable): if {[string range $database 0 1] != "::"} { ::emerald::data::prepend database [uplevel 1 {namespace current}] ::} This code works fine all the time, except when '''namespace current''' returns ''::''. ''database'' then becomes something like ''::::procedure'' instead of ''::procedure''. I'm going to do a check with [if] and not prepend ''::'' for this result for now, can anyone recommend a better solution? I think ''namespace current'' needs an argument like '''-actual''' to prevent this behaviour. -- [RS]: Except for ugly looks, :::: will not hurt your program execution, as "two or more colons" are parsed as namespace separator. -- [schlenk] You may even use the wrong tool for the job, [namespace which] could be more like what you want. [Jasp] Ah!, why did I miss [namespace which] while reading the manual?, knowing of it will help. Currently in the procedure of this code, the procedure specified in ''database'' may not yet exist, but only when using certain "subcommands". However with your notes in mind, I should be able to modify it to work correctly without current hack. Thanks. :) [NEM] For names that don't yet exist, I use these little utility procs: proc nsjoin {ns name} { if {![string match ::* $name]} { set name [string trimright $ns :]::$name } return $name } proc resolve name { nsjoin [uplevel 1 { namespace current }] $name } (I also don't like names like ::::foo - two colons is ugly enough). [Jasp] The problem with '''nsjoin''' there, is that it only removes one bit of excessive colons. The procedure I'm working on keeps a database of infomation for the procedures it works with (which are sort of like objects, but not exactly), and if a procedure is specified as both ''foo::bar'' and ''foo::::bar'' without being normalized in a way, then it could keep two seperate records for the same procedure, not the wanted behaviour. - [RS] A simple fix would be, called after composing namespaced names, regsub -all :::+ $name :: name [Jasp] I was thinking something like that. ---- See also: * [namespace] * [namespace children] * [namespace parent] ---- [Category Command] - [Tcl syntax help]