BinaryByter
because there is no return to the function
Jussi
Why not?
BinaryByter
because thats how goto works
BinaryByter
Jussi
Can you even jump to another scope with goto?
Jussi
I understand now what you mean
Jussi
Can you even jump to another scope with goto?
And if you can, it's weird if the compiler cannot handle the stack cleaning
Jussi
But imo goto is not that bad inside the same scope, that's how I've seen it been used anyway
BinaryByter
Well it is predictible
BinaryByter
but its hard to keep track of
Jussi
It can be yes
Jussi
Mm
BinaryByter
It adds complexity which your coworkers might have trouble with
BinaryByter
additionally, goto is nothing but a very very thing wrapper around assembler
BinaryByter
meaning that you are made to do the compilers job at not leaking
Mat
But imo goto is not that bad inside the same scope, that's how I've seen it been used anyway
If you can have a clearer code structure with the same effort, why not?
Jussi
If you can have a clearer code structure with the same effort, why not?
And if you can have it clearer with goto, why not :)
BinaryByter
Goto is like calling another function
Jussi
I mean I never use it but sometimes I come across in someone else's code
BinaryByter
Goto is like calling another function
meaning that you put 20 different functions into a single one
Mat
And if you can have it clearer with goto, why not :)
It's really hard goto will make it clearer
Jussi
Depends on the taste I guess
BinaryByter
No
BinaryByter
it does not
BinaryByter
if your taste is "I put 20 functions into a single one", you have a shitty taste
Mat
Depends on the taste I guess
A clear code is taste-independent
Jussi
:D
Liam
The only reasonable use of goto is to jump out of deeply nested loops. However, Deeply nested loops themselves are not recommended. So..., preventing using goto is almost always right.
Liam
Something like: for(...) { for(...) { while(...) { if(...) goto stop; . . . } } } stop: std::cout << "Error in program.\n";
BinaryByter
The only reasonable use of goto is to jump out of deeply nested loops. However, Deeply nested loops themselves are not recommended. So..., preventing using goto is almost always right.
If, while etc are their own scopes with variables. Depending on how the compiler implements the vars, jumping out might leak
BinaryByter
+ break and continue are enough
Liam
Anyway, preventing using goto is political correct in C/C++ world.
Aquib
Java has some civilized form of goto but otherwise you cannot use them
Aquib
Anyway, preventing using goto is political correct in C/C++ world.
Absolutely. Goto causes more problems than it solves
Vitaliy ◀️TriΔng3l▶️
If it solves a problem, it's a valid solution
Anonymous
Can we make gui applications using C/C++?
Liam
Yes.
Liam
Most games on PC are built by C++.
Anonymous
What tools are use in making gui applications?
Anonymous
I mean the ide?
Anonymous
Best recommended ide?
Anonymous
Thanks.
Jussi
Qt/Windows forms api whatever/GTK+
Francisco
If it solves a problem, it's a valid solution
All loops are esentially gotos, but abstraction is what make them understandable
Vitaliy ◀️TriΔng3l▶️
All loops are esentially gotos, but abstraction is what make them understandable
Except when you add mess to avoid goto where goto would be obvious
Francisco
Except when you add mess to avoid goto where goto would be obvious
Never been in the situation where I felt I needed a goto
Vitaliy ◀️TriΔng3l▶️
Like additional conditions on outer loops in the most common example of goto with exiting an inner loop
Vitaliy ◀️TriΔng3l▶️
goto clearly describes the intention in this case, and is self-sufficient, doesn't require additional checks in every outer loop
Vitaliy ◀️TriΔng3l▶️
if you don't need it anymore at some point in the future, you just remove the goto and the label, removing exactly what you wanted to remove
Francisco
if you don't need it anymore at some point in the future, you just remove the goto and the label, removing exactly what you wanted to remove
Well, you must have used a lot of gotos in your life, because I don't think it'd be that easy to factor all that spaghetti code full of gotos
Vitaliy ◀️TriΔng3l▶️
Well, you must have used a lot of gotos in your life, because I don't think it'd be that easy to factor all that spaghetti code full of gotos
Religiously avoiding gotos for the sake of avoiding gotos and writing code full of gotos is the same kind of stupid, just in different extremes of it
Vitaliy ◀️TriΔng3l▶️
What I'm saying is when they let you express control flow in a richer and more descriptive way, why not
Vitaliy ◀️TriΔng3l▶️
Never been in that situation
The most basic example — nested loops?
MᏫᎻᎯᎷᎷᎬᎠ
This whole conv all about goto
Vitaliy ◀️TriΔng3l▶️
for some elements { for some elements for this element { if condition met, we found something, stop searching } }
Vitaliy ◀️TriΔng3l▶️
Or error handling in C
Francisco
The most basic example — nested loops?
If you have very deeply nested loops, you should reconsider your algorithm
Vitaliy ◀️TriΔng3l▶️
Vitaliy ◀️TriΔng3l▶️
Or error handling in C
Exceptions are exceptional situations, not something that should increase the indentation level of your normal control flow
Anonymous
Watan: The is the last option i got. To ask strangers on telegram who know how to code. I know this will sound boring but, i have an idea. Trust me, its not related to game, or some messaging or some social app. Its very simple if anyone know the basics of app development they can do it because i dont think im in that feild and also i don't have time.If anyone one is a bit interested in knowing and helping pls text me back.
Vitaliy ◀️TriΔng3l▶️
I try not to use them, I prefer waiting for contracts
I mean in C, and exceptions as a concept of an error situation, not the specific C++ construct
Anonymous
👍
Vitaliy ◀️TriΔng3l▶️
The other option is putting lots of `return`s with all the cleanup
Vitaliy ◀️TriΔng3l▶️
But then you get code duplication, and for everything you create all of the handlers below become bigger
Vitaliy ◀️TriΔng3l▶️
How many inner loops do you have?
Sometimes 2-level, sometimes 3-level
Vitaliy ◀️TriΔng3l▶️
Or you mean instances of nested loops?
Mat
Sometimes 2-level, sometimes 3-level
I think that's the answer
Mat
Do you require gotos to exit them?
Vitaliy ◀️TriΔng3l▶️
Do you require gotos to exit them?
Not necessarily, but it helps when you have multiple exit conditions in the inner loop