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.
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...
1) Can variables be exported from a namespace in addition to procs? This is
to avoid having to explicitly say "foo::var1".
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> }".
> -----Original Message-----
> From: Moses DeJong [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 02, 1999 8:47 PM
> To: [EMAIL PROTECTED]
> Subject: [Tcl Java] Re: [Tcl Java] namespace
>
>
> On Tue, 2 Nov 1999, Thomas McKay wrote:
>
> Nope, you need to use "namespace eval {...}"
>
> Try this.
>
> % namespace eval foo {
> variable x
> set x 12
> }
>
> % set foo::x
> 12
>
>
> You can create a namespace like this "namespace eval foo {}".
>
> If you run into problems, please check to see if you code
> works in Tcl 8.X. If you find code that does not work the
> same as Tcl 8.X, I want to hear about it.
>
> later
> mo
>
> > Should the following work?
> >
> > namespace foo {
> > variable x
> > set x 12
> >
> > proc y { a } {
> > puts $y
> > }
> > }
> >
> > I get an unrecognized arg foo, should be eval, etc. Looking at
> the code it
> > sure seems like this won't work.
> >
> > How do I create a namespace then?
> >
> > ---
> > Thomas McKay
> >
> > Project Leader
> > Microcosm Technologies, Inc.
> > mailto:[EMAIL PROTECTED]
> >
> > ----------------------------------------------------------------
> > 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]'.
> >
>
> ----------------------------------------------------------------
> 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]'.
----------------------------------------------------------------
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]'.