what is: variable Mytest() ? 
Author Message
 what is: variable Mytest() ?

Hi
I have some very old scripts, which work with tcl8.0.1 and have
something like this:

#### begin #####

namespace eval ::MyNamespace {

        variable MyTest()

        proc test {} {
                variable MyTest
                set MyTest(something) "some_value"
        }

Quote:
}

#### end #####

I've tried to run these scripts with 8.4.13 and I got:
'can't define MyTest(): name refers to an element in an array while
executing
variable MyTest()'

I've tried 'variable MyTest', and I got:
'can't set MyTest(something): variable isn't array'

What is wrong? I don't understand what was the first intention of using
'variable MyTest()' Any ideas?

Bogdan



Mon, 29 Sep 2008 19:43:08 GMT  
 what is: variable Mytest() ?
variable  myTest
array  set  myTest  {}


Mon, 29 Sep 2008 21:03:09 GMT  
 what is: variable Mytest() ?

Quote:
> variable  myTest
> array  set  myTest  {}

almost good, it's enough 'array set myTest {}' instead of 'variable
myTest' or 'variable  myTest()'

thanks!
Bogdan



Mon, 29 Sep 2008 21:22:43 GMT  
 what is: variable Mytest() ?

Quote:
>> variable  myTest
>> array  set  myTest  {}

> almost good, it's enough 'array set myTest {}' instead of 'variable
> myTest' or 'variable  myTest()'

No, Maurice is correct.  Use the [variable] command to unambigously
determine that "myTest" refers to ::MyNamespace::myTest and not to
any ::myTest variable that might exist.

--
| Don Porter          Mathematical and Computational Sciences Division |

| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|



Mon, 29 Sep 2008 23:31:18 GMT  
 what is: variable Mytest() ?

Quote:

> I have some very old scripts, which work with tcl8.0.1...
> namespace eval ::MyNamespace {
>    variable MyTest()

This bug was fixed in version 8.3.0.


...
        * generic/tclVar.c: Changed behavior of variable command when name
        refers to an element in an array (ie, "variable foo(x)") to always
        return an error, regardless of existance of that element in the
        array (now behavior is consistant with docs too) (bug #981).

--
| Don Porter          Mathematical and Computational Sciences Division |

| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|



Mon, 29 Sep 2008 23:41:12 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. newbie: from mytest import Foo

2. (make-hash-table :test #'mytest)

3. Saving a Variable to a field in a record- what am i doing wrong

4. I am not deaf, but am I mute?

5. Class variables / global variables / Init variables

6. J and variable variables

7. awk variables --> shell variables

8. Variable "Variables"

9. concatenate two variables in a variable

10. Processing variable length/variable data files

11. variable contents to variable name

12. Variable Variables???

 

 
Powered by phpBB® Forum Software