mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 05:53:39 +00:00
compiler: implement deferring of immediately-applied closures
This is a common operation:
freevar := ...
defer func() {
println("I am deferred:", freevar)
}()
The function is thus an immediately applied closure. Only this form is
currently supported, support for regular (fat) function pointers should
be trivial to add but is not currently implemented as it wasn't
necessary to get fmt to compile.
This commit is contained in:
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
hello from function pointer: 5
|
||||
deferring...
|
||||
...run as defer 3
|
||||
...run closure deferred: 4
|
||||
...run as defer 1
|
||||
bound method: foo
|
||||
thing inside closure: foo
|
||||
inside fp closure: foo 3
|
||||
Reference in New Issue
Block a user