Dear XOTcl-guys! I tried to upgrade from Tcl8.4+XOTcl1.5.3 (all my projects worked fine here!) to Tcl8.5b1, but my projects won't run due to some XOTcl problems. The following snippet is extracted from my project and I tested it with XOTcl1.5.5 (from WinTclTk) and XOTcl1.5.6 from ActiveState-Teacup. But both failed with the same error message. My guess: Non-positional Arguments don't work!
# ************************************************************************ ***** # The script:
Class X X instproc ListOfStringsOption {{-default {}} {-cb {}} name} { if {$cb eq {}} { set cb "::set ::$name " } ;# global variable eval $cb $default } ::X create x1 ::x1 ListOfStringsOption uu
# ************************************************************************ ***** # Error message: can't read "default": no such variable while executing "::set ::uu $default" ("eval" body line 1) invoked from within "eval $cb $default" (procedure "ListOfStringsOption" line 5) ::x1 ::X->ListOfStringsOption invoked from within "::x1 ListOfStringsOption uu"
You are right,
there seems to be a problem with default values for nonpos args in tcl 8.5 after the var reform changes. i will look into the problem today evening or tomorrow morning.
best regards -gustaf neumann
Murr, Florian schrieb:
Dear XOTcl-guys! I tried to upgrade from Tcl8.4+XOTcl1.5.3 (all my projects worked fine here!) to Tcl8.5b1, but my projects won't run due to some XOTcl problems. The following snippet is extracted from my project and I tested it with XOTcl1.5.5 (from WinTclTk) and XOTcl1.5.6 from ActiveState-Teacup. But both failed with the same error message. My guess: Non-positional Arguments don't work!
#
# The script:
Class X X instproc ListOfStringsOption {{-default {}} {-cb {}} name} { if {$cb eq {}} { set cb "::set ::$name " } ;# global variable eval $cb $default } ::X create x1 ::x1 ListOfStringsOption uu
#
# Error message: can't read "default": no such variable while executing "::set ::uu $default" ("eval" body line 1) invoked from within "eval $cb $default" (procedure "ListOfStringsOption" line 5) ::x1 ::X->ListOfStringsOption invoked from within "::x1 ListOfStringsOption uu"
Xotcl mailing list Xotcl@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
Murr, Florian schrieb:
Dear XOTcl-guys! I tried to upgrade from Tcl8.4+XOTcl1.5.3 (all my projects worked fine here!) to Tcl8.5b1, but my projects won't run due to some XOTcl problems. The following snippet is extracted from my project and I tested it with XOTcl1.5.5 (from WinTclTk) and XOTcl1.5.6 from ActiveState-Teacup. But both failed with the same error message. My guess: Non-positional Arguments don't work!
Dear all,
not sure if this helps immediately, since your are refering to binary distros, but however, below is the fix to the problem. Tcl 8.5 seems much more agressive in sharing variables. The variable was set, but lost later, maybe due to shimmering. Switching back to the more conservative approach helps. The change will be included in the next xotcl release.
best regards -gustaf neumann
--- generic/xotcl.c~ 2007-10-09 20:44:45.000000000 +0200 +++ generic/xotcl.c 2007-10-29 21:48:13.000000000 +0100 @@ -11438,9 +11438,9 @@ r1 = Tcl_ListObjGetElements(in, nonposArgsDefv[i], &npac, &npav); if (r1 == TCL_OK) { if (npac == 3) { - Tcl_ObjSetVar2(in, npav[0], NULL, npav[2], 0); + Tcl_SetVar2Ex(in, ObjStr(npav[0]), NULL, npav[2], 0); } else if (npac == 2 && !strcmp(ObjStr(npav[1]), "switch")) { - Tcl_ObjSetVar2(in, npav[0], NULL, Tcl_NewBooleanObj(0), 0); + Tcl_SetVar2Ex(in, ObjStr(npav[0]), NULL, Tcl_NewBooleanObj(0), 0); } } }
Just a small followup: Since xotcl has about 30 tests for nonposargs, which are all passing for tcl 8.5, i was trying to extend the xotcl regression test, and found some more insight:
Your original script
Class X X instproc ListOfStringsOption {{-default ""} {-cb ""} name} { if {$cb eq {}} { set cb "::set ::$name " } ;# global variable eval $cb $default }
could be as well be repaired in 8.5 by avoiding eval with the new-style expand operator
X instproc ListOfStringsOption {{-default {}} {-cb ""} name} { if {$cb eq {}} { set cb "::set ::$name " } ;# global variable {*}$cb $default }
or strangely, by mentioning the variable "default" explicitely in the procbody
X instproc ListOfStringsOption {{-default ""} {-cb ""} name} { if {$cb eq {}} { set cb "::set ::$name " } ;# global variable set _ $default eval $cb $default }
I have still no clear understanding why in the original version the variable "default" is unknown within eval. Maybe there is a bad interaction with the byte-code compiler in Tcl 8.5...
Anyhow, altering Tcl_ObjSetVar2() to Tcl_SetVar2Ex() on the C level works fine in all cases.
best regards -gustaf neumann