> -----Original Message-----
> From: Kenneth Jacker [mailto:[EMAIL PROTECTED]] 
> 
>   damon> The main and init procedures are there as guidelines, but you
>   damon> can replace them with any content you wish.  I do exactly
>   damon> what you're talking about all the time.  I put all of my GUI
>   damon> code into a file called windows.tcl and all my application
>   damon> code into something like utils.tcl or common.tcl.  Then, in
>   damon> my init procuedure, I can just source the .tcl files as
>   damon> needed.
> 
> 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

Bob
-- 
Bob Techentin                        [EMAIL PROTECTED] 
Mayo Foundation                                 (507) 538-5495 
200 First St. SW                            FAX (507) 284-9171
Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/ 


_______________________________________________
vtcl-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/vtcl-user

Reply via email to