-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
if-let
breaks tail call optimization.
#1401
Comments
if-let
breaks tail call optimization.
Changes to avoid multiple macro expansions of the "false" branch caused a regression in this functionality.
@amano-kenji May be you can see if 9e0daae fixed things for you? |
It fixes the tail call optimization, but the fiber call stack for false branch points to the top of For the true branch, the call stack points to the line where Other than that, it's fine. It's only a minor issue. |
This is my test code. (defn recurse
[branch]
(if-let [ha branch]
(do
(ev/sleep 1)
(debug/stacktrace (fiber/current) "print stack for true branch" "")
(recurse branch))
(do
(ev/sleep 1)
(debug/stacktrace (fiber/current) "print stack for false branch" "")
(recurse branch))))
(recurse false) |
Ok, to spell out some details...with the following in (defn recurse
[branch]
(if-let [ha branch]
(do
(ev/sleep 1)
(debug/stacktrace (fiber/current) "print stack for true branch" "")
(recurse branch))
(do
(ev/sleep 1)
(debug/stacktrace (fiber/current) "print stack for false branch" "")
(recurse branch))))
(defn main
[& args]
(def arg
(case (get args 1 "true")
"true" true
"false" false
nil))
(recurse arg)) For the invocation
where line 6, column 7 refers to the code: (debug/stacktrace (fiber/current) "print stack for true branch" "") which is fine, but, for the invocation
where line 3, column 3 refers to the code: (if-let [ha branch] which I guess would be nicer if this was actually pointing at: (debug/stacktrace (fiber/current) "print stack for false branch" "") (line 10, column 7). |
I guess the location information reporting situation mentioned in this comment is a different issue. |
Closing this to create another issue. |
if-let
macro and all other macros that depend onif-let
macro break tail call optimization.I don't know what other macros break tail-call optimization.
The text was updated successfully, but these errors were encountered: