On Wed, 3 Nov 1999, Thomas McKay wrote:
The book is wrong in this one example. This is a namespace feature that
was changed (in Tcl 8.1 I think). Originally, it seemed like a good idea
to be able to leave out the eval but I guess they reconsidered.
> Gotcha. The book I have Tcl/Tk by Welch has examples of namespace w/o the
> 'eval'. Is the book wrong? It says it describes Tcl 8.0. I just want to
> know what Tcl book to recommend to customers.
Namespaces remove "global conflict" for variables and procs but it
does not give you "instance" data like itcl does. In itcl, you
can create instances of a class that have their own vars.
Problem is, Jacl does not have an Itcl port.
> 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...
Nope, you can not export a variable from a namespace. You could try some
kind of wacky trace on a global variable and then set the namespace var
is the callback.
> 1) Can variables be exported from a namespace in addition to procs? This is
> to avoid having to explicitly say "foo::var1".
I thought of that too. You could try something like.
proc getinput { } {
gets stdin var
namespace eval foo $var
}
> 2) Is there a way to switch to a namespace so that all evals after then take
> place w/in that namespace? I suppose I could simply wrap all user input in
> "namespace eval foo { <user input> }".
>
later
mo
----------------------------------------------------------------
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]'.