Tech
goto's underrated
goto is absolutely underrated.
it isn't inherently bad. like any control-flow tool, it depends on how exactly you'd use it.
proper usage:
gotoif (error!=0) {do_cleanup}
// complete_operation
label do_cleanup
sys.unlock_file(descriptor)
sys.free(buffer)
return
this is pretty simple: if something goes wrong, go clean up.
messed-up usage:
@label b
goto a
@label c
goto b
@label a
goto c
// a forever do-nothing loop
this is technically valid, but...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to