You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
here is an implementation of the array foreach improvement. I changed the interface to be more similar to that of dict for: array for {varName varName} arrayName { code }, are you O.K. with that? If so, I'll write required documentation changes and propose it for inclusion in Tcl core. As a bonus, you can use this today, no need to wait on a new Tcl release.
Thank you,
Adrián
proc::tcl::array::for {variableNames arrayName code} {
::upvar 1 $arrayName arr;
::tailcall ::foreach $variableNames [::array get arr] $code
}
::namespace ensemble configure array -map \
[dict replace [::namespace ensemble configure array -map] \for ::tcl::array::for];
# Example usage:array set myarr {
x 1
y 2
z 3
}
array for {key val} myarr {
puts"$key=$val";
}
The text was updated successfully, but these errors were encountered:
A previously existing TIP was opened by karl years ago but never finished. The template might be reuable as the basis for this new TIP. http://www.tcl.tk/cgi-bin/tct/tip/421.html
Please note that the primary motivation of this enhancement is not just a syntactic improvement, but an actual performance improvement by eliminating the need to duplicate the array with [array get]
Hello,
here is an implementation of the
array foreach
improvement. I changed the interface to be more similar to that of dict for:array for {varName varName} arrayName { code }
, are you O.K. with that? If so, I'll write required documentation changes and propose it for inclusion in Tcl core. As a bonus, you can use this today, no need to wait on a new Tcl release.Thank you,
Adrián
The text was updated successfully, but these errors were encountered: