namespace eval bug or feature? 
Author Message
 namespace eval bug or feature?

I think that I have found a bug in the namespace eval command. It looks
like the local
variables from a function are not visible in a string that is passed to
namespace evel.
Here is some example code that demonstrates the differences between eval
and namespace eval.

mo dejong


proc p { arg } {
 set str "puts \$arg"
 eval $str

Quote:
}

namespace eval buggy {
 proc p { arg } {
  set str "puts \$arg"
  namespace eval :: $str
 }

Quote:
}

p 1
#1

buggy::p 1
#can't read "arg": no such variable



Fri, 17 Mar 2000 03:00:00 GMT  
 namespace eval bug or feature?

Quote:

> I think that I have found a bug in the namespace eval command.
[snip]
> namespace eval buggy {
>  proc p { arg } {
>   set str "puts \$arg"
>   namespace eval :: $str
>  }
> }

That's a bug in your code, not in Tcl.  You're asking Tcl to evaluate
the string "puts $arg" in the global context and it's complaining that
there isn't a variable called "arg" in that context.  You wouldn't
expect

        uplevel #0 $str

to work would you?

--
John Haxby

----------------------------------------------------------------
These are my opinions, not my employer's.



Sat, 18 Mar 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. namespaces: bug or feature?

2. "namespace import": bug or feature?

3. Is this a namespace bug or a feature?

4. BUG/PROBLEM: Tcl8.0b1 namespace children/delete {} in a namespace

5. namespace eval ... {} [was:BWidgets]

6. breaking 'namespace eval'

7. Namespace eval context inconsistency

8. namespace eval myspace { info commands }

9. Selector Namespaces: A Standard Feature for Smalltalk?

10. Selector Namespaces: A Standard Feature for Smalltalk?

11. eval-context problem (bug?)

12. Weird bug with eval

 

 
Powered by phpBB® Forum Software