Groups | Search | Server Info | Login | Register


Groups > comp.lang.tcl > #55609

Re: Bug in namespaces in 9.1?

From Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk>
Newsgroups comp.lang.tcl
Subject Re: Bug in namespaces in 9.1?
Date 2026-03-22 22:54 +0000
Organization A noiseless patient Spider
Message-ID <10pprv5$3ljr2$4@dont-email.me> (permalink)
References <10pot7p$3bbff$1@dont-email.me> <10ppf0v$3gm52$1@dont-email.me>

Show all headers | View raw


On 22/03/2026 19:13, Harald Oehlmann wrote:
> Am 22.03.2026 um 15:09 schrieb Simon Geard:
>> I've had a couple of scripts which work fine in 8.6 but fail in 9.0
>> and 9.1 Below is a small program that exhibits this change of behaviour:
>>
>> namespace eval GUI {
>>
>>      variable x_counter 1
>>
>>      proc create {} {
>>          puts "\tGUI::create => $GUI::x_counter"
>>      }
>> }
>> puts "Tcl patchlevel = [info patchlevel]"
>> puts "\tGUI exists = [namespace exists GUI]"
>> puts "\tGUI::x_counter exists = [info exists GUI::x_counter]"
>> puts "\tx_counter = $GUI::x_counter"
>>
>> if {[catch {GUI::create} err]} {
>>      puts "\t***Error: $err"
>> } else {
>>      puts "\t*** Success ***"
>> }
>>
>> Output:
>> Tcl patchlevel = 8.6.13
>>          GUI exists = 1
>>          GUI::x_counter exists = 1
>>          x_counter = 1
>>          GUI::create => 1
>>          *** Success ***
>>
>> Tcl patchlevel = 9.0.0
>>          GUI exists = 1
>>          GUI::x_counter exists = 1
>>          x_counter = 1
>>          ***Error: can't read "GUI::x_counter": no such variable
>>
>> Tcl patchlevel = 9.1a1
>>          GUI exists = 1
>>          GUI::x_counter exists = 1
>>          x_counter = 1
>>          ***Error: can't read "GUI::x_counter": no such variable
>>
>>
>> To me this looks like a bug since the variable exists and it'd be
>> really strange for a variable to exist that causes a crash when used.
>>
>> Thanks for any help.
>>
>> Simon
>>
> 
> Dear Simon,
> this is intended. You are using a miss-behaviour of 8.6, that it
> searches a variable not starting with "::" in the global namespace, if
> it is not found in the current namespace.

Was that 8.6 behaviour intended at the time by its implementer,
reviewers and enjoyed for its utility by scripters at the time or almost
completely disregarded?

What are the reasons for the choice to search the toplevel or not? I
recall that searching top-level namespaces in most scripting languages
with tcl-namespace-like features is desirable to facilitate migrating
first approximation scripts to more structured expressions.

Is it only a mis-behaviour by today's tcl developers' judgement but
desirable by other days' developers' judgement?


-- 
Tristan Wibberley

The message body is Copyright (C) 2026 Tristan Wibberley except
citations and quotations noted. All Rights Reserved except that you may,
of course, cite it academically giving credit to me, distribute it
verbatim as part of a usenet system or its archives, and use it to
promote my greatness and general superiority without misrepresentation
of my opinions other than my opinion of my greatness and general
superiority which you _may_ misrepresent. You definitely MAY NOT train
any production AI system with it but you may train experimental AI that
will only be used for evaluation of the AI methods it implements.

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


Thread

Bug in namespaces in 9.1? Simon Geard <simon@whiteowl.co.uk> - 2026-03-22 14:09 +0000
  Re: Bug in namespaces in 9.1? Harald Oehlmann <wortkarg3@yahoo.com> - 2026-03-22 20:13 +0100
    Re: Bug in namespaces in 9.1? Simon Geard <simon@whiteowl.co.uk> - 2026-03-22 20:17 +0000
      Re: Bug in namespaces in 9.1? Emiliano <emiliano@example.invalid> - 2026-03-23 02:02 -0300
        Re: Bug in namespaces in 9.1? Harald Oehlmann <wortkarg3@yahoo.com> - 2026-03-23 10:16 +0100
    Re: Bug in namespaces in 9.1? Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk> - 2026-03-22 22:54 +0000

csiph-web