Created
February 16, 2021 11:19
-
-
Save mrcalvin/ccb7197081f2b8fa4be328d86b0c00f6 to your computer and use it in GitHub Desktop.
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
| # https://stackoverflow.com/questions/66201923/upvar-tcloo-and-next-explanation-of-perhaps-unexpected-behaviour | |
| oo::class create C1 { | |
| variable aDict | |
| method addone {} { | |
| dict incr aDict xx | |
| } | |
| method getADict {} { | |
| return $aDict | |
| } | |
| } | |
| oo::class create S1 { | |
| superclass C1 | |
| method addone {} { | |
| my variable aDict | |
| next; | |
| dict incr aDict xx; | |
| } | |
| } | |
| oo::class create S2 { | |
| superclass C1; | |
| method addone {} { | |
| my variable aDict | |
| next | |
| dict incr aDict xx 2; | |
| } | |
| } | |
| set s1 [S1 new]; | |
| set s2 [S2 new]; | |
| $s1 addone; | |
| puts [$s1 getADict]; | |
| $s2 addone; | |
| puts [$s2 getADict]; | |
| # Local variables: | |
| # mode: tcl | |
| # tcl-indent-level: 2 | |
| # indent-tabs-mode: nil | |
| # End: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment