> > You place the "source" command *within* the "init" proc?
> >
> > Seems like you'd do it outside of all proc bodies (like a
> > "#include" in C/C++), otherwise the "scoping" would be weird, no?
>
> Yes, exactly.
>
> In C/C++, scoping is a compiler-per-file thing. You can hide functions from
> the linker with "static" declarations, or play tricks with scoping so that
> the compiler prevents one function from seeing another. But all functions,
> variables, structures and objects eventually end up in the "global" memory.
> Once you get past the compiler and linker, you can get to anythign with a
> pointer. Think of it as one big flat namespace.
>
> Tcl doesn't have pointers. Procs have names. And they all end up (by
> default) in the global namespace. Even if you define them inside another
> proc. Variables defined within a proc are usually local to the proc, so you
> will need to include a global command, even if your variable declarations
> are at global scope within the sourced file.
>
> If your application gets "large", you might consider using namespaces to
> keep things organized. See Will's guide to success with namespaces and
> packages at http://www.wjduquette.com/tcl/namespaces.html
The simplest way to make sure that all of your variables are scoped
at the global level is to just execute the source command at the global
level. This is done through Tcl's uplevel command. Like this:
## #0 is stack 0, the global namespace.
uplevel #0 source someFile.tcl
This will execute the source command at level 0, the global stack.
Then, you can be sure that all of your variables that are meant to be
global are.
Damon
_______________________________________________
vtcl-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/vtcl-user