| Ticket UUID: | 629b11ac299f550eb878c7bda08e75c1f7d579a7 | |||
| Title: | Migration tool warnings for Tk 9.0b3 | |||
| Type: | Bug | Version: | 9.0b3 | |
| Submitter: | apnadkarni | Created on: | 2024-08-01 11:04:46 | |
| Subsystem: | (unused) | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2024-08-05 13:27:04 | |
| Resolution: | Fixed | Closed By: | oehhar | |
| Closed on: | 2024-08-05 13:27:04 | |||
| Description: |
Following warnings generated by the tcl9 migration tool against Tk (beta 3 release. False positives possible. Caveat emptor.
| |||
| User Comments: |
oehhar added on 2024-08-05 13:27:04:
As the "portability" warning is only critical for 8.7, it was now merged for 8.7 with commit [1df28451]. For the beauty, it is also merged to 9.0 with commit [505f9fd8]. The old bug branch is hidden and closed now. I close the bug now. The remaining warnings for "string is int" are mostly harmless. There should be checks for the ranges, but it is not special to this ticket. Thank you all, Harald nemethi (claiming to be Csaba Nemethi) added on 2024-08-05 10:55:09: Like Harald, up to now I haven't been aware of the peculiarity of Tcl versions earlier than 9 mentioned by Ashok, namely that a set invocation within a namespace overwrites an existing global variable of the same name. Now I understand why the migration tool generates a warning, and find the fix OK. Thanks to both of you! oehhar added on 2024-08-05 07:34:50: Replaced "set" by "variable" due to potential side effects if used in TCL 8.7 (maybe, it might be back-ported) with commit [bb91eb8e] in branch [bug-629b11ac-namespace-set-variable]. As I have a talent to make everything worse, I would really appreciate a review. As I am on Windows, I never use this code. So, I did not do any test run. A test by: ::tk::dialog::file:: open showed up correctly. Thanky ou for all, Harald oehhar added on 2024-08-02 08:27:18: Hi Ashok, thank you. Slowly, I get it. But that is even worse. If the program has the value, it is overwritten, otherwise not. That is a serious serious, I was not aware of. Any "set" within a namespace in TCL 8.6/8.7 is very dangerous. TCL 8.7 also behaves like 8.6 in this respect. So, I would favor to change this. In addition, I would love, if Kevin Walzer could review the "string is entier" ones, as some check ranges, some not. Thanks for all, Harald apnadkarni added on 2024-08-02 08:17:35: The issue is only if the global already existed, it is overwritten in 8.6
I see it as more of an issue with 8.6 than 9.0. I would not worry about it if the author feels comfortable with it. In general, the migrate messages are only meant as suggestions that the programmer should review, not that something is necessarily wrong. oehhar added on 2024-08-02 06:58:29: Thanks, Ashok, for the explanation. The code is shared between 8.7 and 9.0, so it matters. I tried tcl 8.6.14, core-8-branch and main 9.0b3. The result is always the same:
% namespace eval t {set v 1}
1
% set v
can't read "v": no such variable
% proc t::t {} {variable v;puts $v}
% t::t
1
% set v
can't read "v": no such variable
I don't see any creation of a global variable. The variable solution behaves identically:
% namespace eval t {set v 1}
... (identical to above)
The only difference is, that the "variable" command does not return the set value.
I would directly change this, but I am missing the arguments. The code is by Csaba and it is important that he likes the code... Thanks, Harald apnadkarni added on 2024-08-01 16:08:51: Yes, not required. However, that pattern does different things on 8.6 versus 9.0. In 8.6 it will create a global. In 9.0 it will create a namespace var. Hence the warning. If the code is no longer shared between 8.x and 9.0, I suppose it does not matter. If the code is the same between 8.x and 9.0, the 8.x version should be fixed as it is creating variables in the global namespace. But perhaps the 8.x code is different. You may close this if you conclude it is not an issue. oehhar added on 2024-08-01 15:45:56: I have asked Csaba about the last ones. He answered, that this is correct. The used pattern is:
% namespace eval t {set v 1}
1
% proc t::t {} {variable v;puts $v}
% t::t
1
This works in TCL 9.0b3. I would find it more beautiful, to use:
% namespace eval t {variable v 1}
but this is not required. Thank you all, Harald oehhar added on 2024-08-01 13:08:32: Yes, great work, very useful tool! Unfortunately, commit [df9f759b] did not make it in the release to remove the -encoding binary ... If the "string is integer" now without range limitation is ok, may not be decided like that. Some check the range later, some not. The set's in the namespace in tkfbox.tcl should imho be "variable". This is linux only code, as others probably use the native widgets. Thanks, Harald | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki