Skip to content
Tcl Source Code View Ticket
Login

View Ticket

re-implement [namespace code]

Open2000423fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 8 years ago
Descriptionplain2008-06-23 03:05:55
[namespace code] constructs a script
using the [namespace inscope] command
to do its work.  [namespace inscope]
is difficult to understand.

I wonder whether the new [apply] command
has enough power to serve as the primitive
on which an equivalent, but different implementation
of [namespace code] could be written.
dkfplain2008-06-23 15:46:51
Logged In: YES 
user_id=79902
Originator: NO

Experimentation indicates that the following is equivalent to 'namespace inscope', apart from the magical horror in [unknown].
  apply {{ns prefix args} {uplevel 1 [list namespace eval $ns $prefix $args]}}

Don't know if this means that it is something you'd actually want to use though. That's not the most elegant code I've written.
tallnielplain2008-06-30 23:25:08
Logged In: YES 
user_id=102050
Originator: NO

My guess is that the following should be roughly equivalent to [namespace code], but
would want to be a lot more sure of that "roughly":

proc ns_code args { list apply [list {} $args [uplevel 1 namespace current]] }

Was that what you were considering, DGP?
msoferplain2008-08-06 21:57:23
Logged In: YES 
user_id=148712
Originator: NO

The ugly hack in init.tcl: we should just REMOVE IT NOW! Let Itcl add that to ::unknown in its own loader, Tcl works fine without that. See Itcl's patch #2040295 at 
https://sourceforge.net/tracker/index.php?func=detail&aid=2040295&group_id=13244&atid=313244
msoferplain2008-08-07 02:24:53
Logged In: YES 
user_id=148712
Originator: NO

Ugly hack in init.tcl now gone
dgpplain2019-06-03 16:15:52
Now that TIP 284 is getting consideration, another look at this may also be in order?
Log in (anonymous is fine) to add a comment.