From: Peter S. <pet...@sp...> - 2003-07-29 20:14:23
|
At 14:41 2003-07-29, D. Richard Hipp wrote: >Has anyone considered syntax like this: > > expand _* destroy [winfo children .] > expand _*____ .b $stdargs -text $mytext -bd $border > expand _**__ $prog $opts1 [getMoropts] $file1 $file2 During the discussions several variations of expand commands that are not syntax based has come up. Of these this is my favourite: # Usage: expand indexlist ?arg arg arg...? # Where indexlist lists each arg to be expanded. # For simplicity, this implementation assumes that no end-style # index will be less than or equal to any numerical index. proc expand {ix args} { foreach i [lsort -unique -dictionary -decreasing $ix] { # 10 points to anyone understanding the line below... set args [eval [linsert [lindex $args $i] 0 lreplace $args $i $i]] } uplevel 1 $args } # Examples from TIP103/144: expand {end} destroy [winfo children .] expand {2} button .b $stdargs -text $mytext -bd $border expand {2 3} exec $prog $opts1 [getMoreopts] $file1 $file2 But generally I prefer a global syntax. If that is declined, I certainly will get into the expand command debate again. /Peter |