[ home / overboard ] [ soy / qa / raid / r ] [ int / pol ] [ a / an / asp / biz / mtv / r9k / tech / v / sude / x ] [ q / news / chive / rules / pass / bans / status ] [ wiki ]

A banner for soyjak.party

/tech/ - Soyence and Technology

Download more RAM for your Mac here
Catalog
Email
Subject
Comment
File
Password (For file deletion.)

File: 1787442050058k.png 📥︎ (58.85 KB, 758x584) ImgOps

 â„–38001[Quote]

If using goto is a bad practice, why none of them ever remove that syntax? Also what's the use for goto?

 â„–38007[Quote]

It's bad practice if integrate it as part of your program's typical flow of execution. Gotos in this case should usually be refactored into other control statements or functions which can easily serve the same purpose and are a lot more readable as they don't require you to look around and match gotos with labels.
Gotos can be useful for error management/cleanup, at least in C (C++ and C# probably have better ways to handle this, I'm not sure). Something like having a cleanup label at the end of a function that handles freeing heap allocated memory or file closing is fine as it is very straightforward to read and prevents a lot of repeated boilerplate code.



[Return][Catalog][Go to top][Post a Reply]
Delete Post [ ]
[ home / overboard ] [ soy / qa / raid / r ] [ int / pol ] [ a / an / asp / biz / mtv / r9k / tech / v / sude / x ] [ q / news / chive / rules / pass / bans / status ] [ wiki ]