Implemented parameter passing for function pointers
This commit is contained in:
parent
b095a95021
commit
9a018f29e7
8 changed files with 71 additions and 44 deletions
|
@ -7,10 +7,10 @@ struct Struct {
|
|||
main() {
|
||||
s := new(Struct)
|
||||
s.func = f
|
||||
s.func()
|
||||
s.func(0)
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
f() {
|
||||
sys.exit(0)
|
||||
f(code int) {
|
||||
sys.exit(code)
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
import core
|
||||
import sys
|
||||
|
||||
main() {
|
||||
func := f
|
||||
func()
|
||||
func(0)
|
||||
sys.exit(1)
|
||||
}
|
||||
|
||||
f() {
|
||||
exit := core.exit
|
||||
exit()
|
||||
f(code int) {
|
||||
exit := sys.exit
|
||||
exit(code)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue