Groups | Search | Server Info | Login | Register


Groups > comp.lang.tcl > #55488

Re: variable ../.. global

From Roderick <hruodr@gmail.com>
Newsgroups comp.lang.tcl
Subject Re: variable ../.. global
Date 2026-02-23 00:09 +0000
Organization MB-NET.NET for Open-News-Network e.V.
Message-ID <50978edb-fbd0-2c16-cacb-e5c7557bc279@gmail.com> (permalink)
References <81ab5038-2ab4-59ae-6058-561da5cf8e92@gmail.com> <10ng392$2hbg4$1@dont-email.me>

Show all headers | View raw


Thanks a lot, Rich!

On Sun, 22 Feb 2026, Rich wrote:

> The docs answer that question for you.  Note last sentence in the quote
> below from the namespace manpage.:
>
>  You can access a namespace variable from a procedure in the same
>  namespace by using the variable command.  Much like the global
>  command, this creates a local link to the namespace variable.  If
>  necessary, it also creates the variable in the current namespace and
>  initializes it.

Very interesting!

Also the two sentences that follow:

"Note that the global command only creates links to variables in
the global namespace. It is not necessary to use a variable command
if you always refer to the namespace variable using an appropriate
qualified name."

I suppose the phrase "links to variables in the global namespace"
in the first sentence means "links to variables relative to
the global namespace".

If I have a variable v in the namespace name, then

"global ::name::v" and "variable v" inside a procedure in
"namespace eval name" will do the same.

It seems the command "variable" is necessary because "global" is
unable to deal with paths relative to the namespace.

Am I wrong?

Rod.

Back to comp.lang.tcl | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

variable ../.. global Roderick <hruodr@gmail.com> - 2026-02-22 22:57 +0000
  Re: variable ../.. global Rich <rich@example.invalid> - 2026-02-22 23:25 +0000
    Re: variable ../.. global Roderick <hruodr@gmail.com> - 2026-02-23 00:09 +0000
      Re: variable ../.. global Rich <rich@example.invalid> - 2026-02-23 03:32 +0000
        Re: variable ../.. global Roderick <hruodr@gmail.com> - 2026-02-23 09:08 +0000
          Re: variable ../.. global Rich <rich@example.invalid> - 2026-02-23 19:41 +0000
            Re: variable ../.. global Roderick <hruodr@gmail.com> - 2026-02-25 07:10 +0000
              Re: variable ../.. global Rich <rich@example.invalid> - 2026-02-25 16:07 +0000
  Re: variable ../.. global Schelte <nospam@wanadoo.nl> - 2026-02-23 09:51 +0100
    Re: variable ../.. global Roderick <hruodr@gmail.com> - 2026-02-23 09:14 +0000

csiph-web