-
-
Notifications
You must be signed in to change notification settings - Fork 121
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
implement defer statement #195
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #195 +/- ##
==========================================
- Coverage 92.02% 90.24% -1.79%
==========================================
Files 9 9
Lines 2270 2317 +47
==========================================
+ Hits 2089 2091 +2
- Misses 118 162 +44
- Partials 63 64 +1
Continue to review full report at Codecov.
|
Anko's defer statement doesn't work like Go's one since anko doesn't have named return parameters for a function. Anko can not re-write return value. Also current implementation doesn't have recover(). |
func foo() {
var i = 0
defer println("foo", i)
i++
defer println("bar", i)
i++
defer println("bar", i)
i++
defer println("bar", i)
i++
defer println("bar", i)
}
foo() This works fine.
|
Could we put the AnonCallExpr and CallExpr in vmExprFunction.go then be able to use it from
Would be really nice if there was a way to merge the two AnonCallExpr & CallExpr so that we do not have to maintain two code areas. |
This implementation is strange since VM run defer even if it is in if/for block. It must be in func block. var time = import("time")
for {
defer println("foo")
time.Sleep(1e9)
} foo must not be appeared. |
I still wonder if some of this code is not needed. Say they do defer something that is not a function, like |
Was curious, is it an issue if the code can defer any expression, not just functions? |
I think maybe we need to execute |
need tests.