Hacker News new | ask | show | jobs
by AndyKelley 917 days ago
Go's defer is incredibly flawed:

1. It only allows function calls instead of any expression.

2. It allocates memory dynamically and attaches the function call expression to the function, rather than the current scope exit. This has surprising and harmful consequences if you use it inside a loop.

So, I wouldn't say that zig's defer is borrowed from Go.

1 comments

Not in implementation but surely in spirit. Didn't you mention in road 1.0 that the idea came from go?

Edit: ok rewatched it and I didn't see that come up, i was just misremembering