> > Here's what I'm trying to do with namespaces; maybe someone has an
> > alternative that would work better:  The application I wrote allows users to
> > open multiple "documents" (I use the term generically here) that may contain
> > Tcl vars and procs specific to the document.  Since there's only one interp
> > these vars can conflict leading to inconsistent results.  I thought that
> > perhaps the namespace feature would be useful in this situation.  However,
> > I'd like to avoid the user from having to understand namespaces by hiding
> > them as much as possible.  Some questions then...

In an earlier application, I did the following to get data specific to a file
into its own namespace:

namespace eval app {

        set doc $filename

        namespace eval ::app::${filename} {

                set fd  [open $filename]
                set all [split [read $fd] \n]

        }
}

When looking up file specific data, I had to do:

set index [eval lsearch -exact \
        [format {$::app::%s::all} $Current_file] $pattern]

cheers,
sam

----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 

Reply via email to