Last active
December 27, 2017 14:13
-
-
Save lepinekong/848c638c4015e570ba966d58367c440b to your computer and use it in GitHub Desktop.
Debug with counter: doesn't work well when calling subfunction
This file contains 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
??: func [ | |
"Prints a word and the value it refers to (molded)" | |
'value [word! path! string!] | |
/start | |
/local cum | |
][ | |
cum: [] | |
; initialization | |
if start [ | |
cum: copy [] | |
] | |
if (empty? cum) [ | |
append cum 0 | |
] | |
; cum | |
cum/1: cum/1 + 1 | |
either (type? :value) = string! [ | |
print rejoin ["[" cum/1 "]" " - " :value] | |
][ | |
prin rejoin ["[" cum/1 "]" " - "] | |
prin mold :value | |
prin ": " | |
print either value? :value [ | |
mold get/any :value | |
] ["unset!"] | |
] | |
] | |
afunc: func[][ | |
a: 1 | |
??/start a | |
asubfunc: func[][ | |
b: 2 | |
?? b | |
c: 3 | |
?? c | |
] | |
asubfunc | |
] | |
afunc: func[][ | |
a: 1 | |
??/start a | |
asubfunc: func[][ | |
b: 2 | |
?? b | |
c: 3 | |
?? c | |
] | |
asubfunc | |
] | |
; see comment on Github | |
afunc ; OK 1 2 3 | |
afunc ; KO 1 4 5 |
Author
lepinekong
commented
Dec 27, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment