Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
skybrian
on Jan 16, 2022
|
parent
|
context
|
favorite
| on:
A simple defer feature for C
It seems like you could just ban that. Defers aren't typically used within loops, so why support it?
clysmic
on Jan 16, 2022
[–]
Sure they are, if there is something that is being acquired at the start of the loop and needs to get released at the end...
skybrian
on Jan 16, 2022
|
parent
[–]
...of the function? You could append to a slice, after setting up a defer to free everything in the slice.
...of the loop? Call a function.
meithecatte
on Jan 17, 2022
|
root
|
parent
[–]
...or just make defer run at the end of the scope.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: