Skip to content

Instantly share code, notes, and snippets.

@tbenst
Created December 5, 2020 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbenst/1d96d33fdfaf34136c7c1726b3f0d225 to your computer and use it in GitHub Desktop.
Save tbenst/1d96d33fdfaf34136c7c1726b3f0d225 to your computer and use it in GitHub Desktop.
function dummy0(x, continuation)
continuation(x * "will fail if x an integer")
end
function dummy1(x, continuation)
continuation(x, x->x)
end
# make functions dummy2, dummy3, ...
# continuation passing style to succintly make long stack trace
for i in 2:20
func_name = Symbol("dummy$i")
func_name1 = Symbol("dummy$(i-1)")
func_name2 = Symbol("dummy$(i-2)")
eval(quote
$func_name(x, continuation) = $func_name1(x, $func_name2)
end)
end
function dummy21(x)
dummy20(x, dummy19)
end
dummy21("Succeeds since we pass a string but ")
dummy21(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment