Skip to content

Instantly share code, notes, and snippets.

@lepinekong
Last active December 27, 2017 14:13
Show Gist options
  • Save lepinekong/848c638c4015e570ba966d58367c440b to your computer and use it in GitHub Desktop.
Save lepinekong/848c638c4015e570ba966d58367c440b to your computer and use it in GitHub Desktop.
Debug with counter: doesn't work well when calling subfunction
??: 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
@lepinekong
Copy link
Author

afunc
[1] - a: 1
[2] - b: 2
[3] - c: 3
afunc
[1] - a: 1
[4] - b: 2
[5] - c: 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment