Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tcl/Tk8.5 upgrade guide

22 views
Skip to first unread message

Helmut Jarausch

unread,
Nov 22, 2007, 4:02:38 AM11/22/07
to
Hi,

(sorry if this is a FAQ, but I couldn't find an answer on the wiki page)

Is there a guide how to upgrade an old Tcl/Tk application to Tcl/Tk 8.5?
Is there a (semi-)automatic way to do it?

Many thanks for a hint,


Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany

Torsten Reincke

unread,
Nov 22, 2007, 4:27:00 AM11/22/07
to

> Is there a guide how to upgrade an old Tcl/Tk application to Tcl/Tk 8.5?
> Is there a (semi-)automatic way to do it?

There is no guide in the sense of a cookbook, where you can find
explanations on how to change your script. All scripts, that work in
the current 8.4 release should run in 8.5 without modifications
(someone correct me, if this is wrong).

What you can find on th wiki is this:

http://wiki.tcl.tk/10630

This is a list with all the changes and enhancements for 8.5. Using
this as a guideline, you should be able to get an overview of the
wealth of new stuff and subsequently update old scripts.

Torsten

Donal K. Fellows

unread,
Nov 22, 2007, 5:15:42 AM11/22/07
to
Torsten Reincke wrote:
> All scripts, that work in
> the current 8.4 release should run in 8.5 without modifications
> (someone correct me, if this is wrong).

Almost all will. Scripts that depend on the exact behaviour of cursor
motion in the [text] widget may have problems, as may scripts that
depend on details of font handling. Oh, and you're SOL if you're on
Mac Classic. :-)

As always, it's not a good idea to write scripts that depend on
formats of particular error messages.

Donal.

sch...@uni-oldenburg.de

unread,
Nov 22, 2007, 5:22:52 AM11/22/07
to

Helmut Jarausch wrote:
> Hi,
>
> (sorry if this is a FAQ, but I couldn't find an answer on the wiki page)
>
> Is there a guide how to upgrade an old Tcl/Tk application to Tcl/Tk 8.5?

Depends how old and how deep you reach into the Tcl/Tk internals.

Basic rules:
If you use only tcl.h, tk.h and the exported functions from the stubs
table your quite safe.
If you go from 8.4 to 8.5 it should be easy, simply recompile.
If you go from 8.x x <4 to 8.5 you may need to fix some CONST stuff
that changed in 8.4.
(see http://wiki.tcl.tk/3669)
If you go from 7.x to 8.5 you can expect some more work.

But:
If you use tclInt.h or other non public interfaces all bets are
off..., try to recompile and see where the compiler bitches.

Michael

Helmut Jarausch

unread,
Nov 22, 2007, 5:34:53 AM11/22/07
to
Torsten Reincke wrote:
>> Is there a guide how to upgrade an old Tcl/Tk application to Tcl/Tk 8.5?
>> Is there a (semi-)automatic way to do it?
>
> There is no guide in the sense of a cookbook, where you can find
> explanations on how to change your script. All scripts, that work in
> the current 8.4 release should run in 8.5 without modifications
> (someone correct me, if this is wrong).

That is (would be) good news.
But my very first test failed, trying
xtem from
http://www.ctan.org/tex-archive/support/xtem_texmenu/xtem/?action=/tex-archive/support/xtem_texmenu/

I get (when pressing the exit button)

bad variable name "geom(.xtemqd)": upvar won't create a scalar variable that
looks like an array element
while executing
"global [set var]"
(procedure "writeVarList2File" line 5)
invoked from within
"writeVarList2File $vst_file $vstWListe "geom prtcmd""
(procedure "vstWriteFile" line 16)
invoked from within
"vstWriteFile $vf"
invoked from within
".a.1.e invoke"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list $w invoke]"
(procedure "tk::ButtonUp" line 22)
invoked from within
"tk::ButtonUp .a.1.e"
(command bound to event)

Sorry, I don't know Tcl very well,
Here is procedure "writeVarList2File"
proc writeVarList2File {file list globl} {# write variable names and values of
list into file
TestPut 3 "<$file><$list><$globl>"
if {[catch "open $file w" FID]==0} {
foreach var $globl {global $var}
foreach var $list {global [set var]; eval puts \$FID \"\$var \$$var\"}
close $FID
TestPut 3 "written:<$FID>"
}
}

Many thanks for your help,
Helmut.

--

miguel

unread,
Nov 22, 2007, 6:57:16 AM11/22/07
to
Helmut Jarausch wrote:
> Torsten Reincke wrote:
>>> Is there a guide how to upgrade an old Tcl/Tk application to Tcl/Tk 8.5?
>>> Is there a (semi-)automatic way to do it?
>>
>> There is no guide in the sense of a cookbook, where you can find
>> explanations on how to change your script. All scripts, that work in
>> the current 8.4 release should run in 8.5 without modifications
>> (someone correct me, if this is wrong).
>
> That is (would be) good news.
> But my very first test failed, trying
> xtem from
> http://www.ctan.org/tex-archive/support/xtem_texmenu/xtem/?action=/tex-archive/support/xtem_texmenu/
>
>
> I get (when pressing the exit button)
>
> bad variable name "geom(.xtemqd)": upvar won't create a scalar variable
> that looks like an array element
> while executing

This statement used to be "useless": it would have created a variable
that is completely unreachable from Tcl code. It is now an error.

What it means is that your code did not really do what you thought it did.

> "global [set var]"
> (procedure "writeVarList2File" line 5)
> invoked from within

> ...


> Sorry, I don't know Tcl very well,

No need to be sorry, let's try to help you improve.

> Here is procedure "writeVarList2File"
> proc writeVarList2File {file list globl} {# write variable names and
> values of list into file
> TestPut 3 "<$file><$list><$globl>"
> if {[catch "open $file w" FID]==0} {
> foreach var $globl {global $var}
> foreach var $list {global [set var]; eval puts \$FID \"\$var \$$var\"}
> close $FID
> TestPut 3 "written:<$FID>"
> }
> }

So: at least one of the elements passed in $list looks like an array
element: "geom(.xtemqd)" -the puts should have failed to list its value.
EXCEPT if the variable "geom" was passed in $globl, or in $list but
before any of its elements. In that case things would have worked
anyway, but not the way you thought.

Or else I am mistaken - it does happen every now and then :)

Quick workaround: catch the global statement:
proc myglobal args {
uplevel 1 [list catch [list global {*}$args]]
}

Good fix 1: remember that you cannot use 'global' nor 'variable' on
individual array elements, make sure you do not try to.

Good fix 2: rewrite that proc, eg like (untested, avoiding 8.5'isms):

proc writeVarList2File {file list globl} {
# write variable names and values of list into file
TestPut 3 "<$file><$list><$globl>"
if {[catch "open $file w" FID]==0} {

# The following line is doing nothing useful?
# foreach var $globl {global $var}

foreach var $list {
upvar #0 $var local
puts $FID "$var $local"


}
close $FID
TestPut 3 "written:<$FID>"
}
}

Note that upvar CAN create a local (scalar!) variable linked to an
individual array element.

HTH
Miguel

Gerald W. Lester

unread,
Nov 22, 2007, 10:27:26 AM11/22/07
to

Also if you were using the dict as an extension in 8.4, you may want to
remove the package require dict since it is now built into 8.5.


--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+

Donal K. Fellows

unread,
Nov 22, 2007, 10:51:21 AM11/22/07
to
Gerald W. Lester wrote:
> Also if you were using the dict as an extension in 8.4, you may want to
> remove the package require dict since it is now built into 8.5.

Ah yes, and there are a number of significant upgrades for dicts about,
including the fact that 8.5's dicts now preserve the order of the keys,
so making for more stable management of iteration and shimmering. (Note
that this wasn't in 8.5b3.)

Donal.

Andreas Leitgeb

unread,
Nov 23, 2007, 9:30:09 AM11/23/07
to
Torsten Reincke <be...@typoscriptics.de> wrote:
>> Is there a guide how to upgrade an old Tcl/Tk application to Tcl/Tk 8.5?
>> Is there a (semi-)automatic way to do it?
> What you can find on th wiki is this:
> http://wiki.tcl.tk/10630

The one change, I'd consider most likely to surprise anyone (who
didn't follow this group or other ressources during the last few
years), is that integer-operations no longer wrap around at 2^31.

keithv

unread,
Nov 23, 2007, 3:27:09 PM11/23/07
to
On Nov 23, 9:30 am, Andreas Leitgeb <a...@gamma.logic.tuwien.ac.at>
wrote:

> Torsten Reincke <b...@typoscriptics.de> wrote:
> >> Is there a guide how to upgrade an old Tcl/Tk application to Tcl/Tk 8.5?

I recently ported a fairly large tcl project to 8.5 and
had two issues that required programming changes.

First, tcl_precision changed and that affected the display
of some numbers. For example,
pack [label .l -textvariable foo]
set foo [expr {2.7 + .6}]

Under 8.4 this displayed 3.3, under 8.5 it shows 3.30000000000003.
I had to fix this by adding additional trace commands and shadow
variables.

Second, grid behavior changed when the widget is smaller than
the container. Tcl 8.5 added the grid anchor command but the
8.5 default is nw while 8.4 behavior was center.

Keith

Donald G Porter

unread,
Nov 26, 2007, 11:19:00 AM11/26/07
to
Helmut Jarausch wrote:
> Is there a guide how to upgrade an old Tcl/Tk application to Tcl/Tk 8.5?

In addition to advice already offered, take a look at the entries in
the "changes" files that are marked ** POTENTIAL INCOMPATIBILITY **.

--
| Don Porter Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|

Larry W. Virden

unread,
Nov 26, 2007, 11:33:05 AM11/26/07
to
On Nov 22, 4:27 am, Torsten Reincke <b...@typoscriptics.de> wrote:
> All scripts, that work in
> the current 8.4 release should run in 8.5 without modifications
> (someone correct me, if this is wrong).
>
> What you can find on th wiki is this:
>
> http://wiki.tcl.tk/10630


This page should cover incompatibilities at the script level. There
may be other incompatibilities. It is my hope that at the very least,
a page covering additional issues is created at http://wiki.tcl.tk/
which could then be added to 10630 for those undergoing the
transition.

Larry W. Virden

unread,
Nov 26, 2007, 11:36:16 AM11/26/07
to
On Nov 22, 10:27 am, "Gerald W. Lester" <Gerald.Les...@cox.net> wrote:
> Donal K. Fellows wrote:
> > Torsten Reincke wrote:
> >> All scripts, that work in
> >> the current 8.4 release should run in 8.5 without modifications
> >> (someone correct me, if this is wrong).
>
> > As always, it's not a good idea to write scripts that depend on
> > formats of particular error messages.
>
> Also if you were using the dict as an extension in 8.4, you may want to
> remove the package require dict since it is now built into 8.5.
>

Well, if you were using Tile as an extension in 8.4, there are some
differences, right? I mean, the name space is ttk:: and, depending on
how old your version of the Tile extension is, there may be some
differences.

Also, there may be new errors where one didn't get them before - that
sort of thing is pretty typically in this type of upgrade.

0 new messages