Re: Variable naming
- From: Bryan Oakley <oakley@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Sep 2006 21:19:10 GMT
Dario D. wrote:
Hello all,
Is slash (/) allowed in variable names? I'm reading a tutorial on the NS2 simulator, and it appears to be using slashes in class names:
Every character (except the sequence ::) is allowed as a variable name.
set tcp [new Agent/TCP]
I tried to run the following example through tclsh, but as you can see it didn't work out well:
% set test/blah 5
5
% puts $test/blah
can't read "test": no such variable
Bear in mind that, although any character is valid for a variable name, the parsing for $ only looks for a subset of all possible characters (as specified in the Tcl man page, rule 7).
Try this:
% set test/blah 5
5
% puts $test/blah
can't read "test": no such variable
% puts ${test/blah}
5
% puts [set test/blah]
5
% info exists test/blah
1
.
- Follow-Ups:
- Re: Variable naming
- From: Joe English
- Re: Variable naming
- Prev by Date: no irc in tcllib?
- Next by Date: Re: no irc in tcllib?
- Previous by thread: Re: Variable naming
- Next by thread: Re: Variable naming
- Index(es):
Relevant Pages
|