Last active
March 9, 2020 07:51
-
-
Save yyamasak/7d9621ca8bea1097028221cb1ee1a10e to your computer and use it in GitHub Desktop.
syntax sugar for foreach once {1} {puts a; break; puts b}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc breakable {script} { | |
uplevel [list foreach __BLOCK__ {1} $script] | |
} | |
if {[info exists ::argv0] && $::argv0 eq [info script]} { | |
set str "line" | |
puts "enter breakable" | |
breakable { | |
puts "1st $str" | |
break | |
puts "2nd $str" | |
} | |
puts "exit breakable" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment