Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2003-08-10
21:44 • Closed ticket [786187ffff]: proc requires a namespace to exist but rename doesn&... artifact: 1e1a3eee24 user: msofer
16:07 • Ticket [786187ffff]: 4 changes artifact: 67132dd58d user: muonics
08:31 • New ticket [786187ffff]. artifact: ac60cb8bdb user: muonics

proc requires a namespace to exist but rename doesn't

Closed / Duplicate786187ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2003-08-10 08:31:48
I found this comment in TclRenameCommand while poking
through the sources, which made me curious:

"Make sure that the destination command does not
already exist.  The rename operation is like creating a
command, so we should automatically create the
containing namespaces just like Tcl_CreateCommand would."

I found this interesting, because I often wind up doing
an namespace eval "" just to make a namespace exist
because I don't usually define my procs within the
eval.  So I ran a test:

% namespace children ::
::tcl
% proc ns::test {} {}
can't create procedure "ns::test": unknown namespace
% proc test {} {}
% rename test ns::test
% namespace children ::
::ns ::tcl

Shouldn't proc be able to do the same?  It would be
quite handy.
muonicsplain2003-08-10 16:07:10
Logged In: YES 
user_id=498198

For that matter, how about set and array set?  I suppose it
might be harder to catch typos in namespace qualifiers, or
broken order of initialization, but it might simplify other
things a little bit.
msoferplain2003-08-10 21:44:08
Logged In: YES 
user_id=148712

In the same spirit as [FR 582926], where the beef starts
with automatic namespace creation for [set] and [upvar] and
ends requesting

  ... whenever a "namespace does not exist"
  error message is currently being returned, 
  instead have the required namespace created
  automatically

I tend to agree it is a bug, and 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?

In any case, closing as a duplicate and incorporating the
example into [FR 582926] seems reasonable.
Log in (anonymous is fine) to add a comment.