Talula
Goto in pretty much any language is bad practice
In original BASIC it was impossible to program without GOTO reason for it were line numbers.
Kat
Except basic lol
Stefan
actually, why dijkstra said goto is cancerous is because its unfortunate couplance with turing machine
Stefan
and not with algorithm
Stefan
if you really look into automata theory, you will see loops are indeed constructed using jumps/goto
olli
then you dont have loops
are you saying you need goto statements to have loops?
Stefan
try to read assembly back and forth, which is already a form of random access machine and a universal turing machine
Stefan
you will see
Stefan
dijkstra wanted people to not think about low level constructs
Stefan
but pure high level thing like algorithm and data structure
olli
jumps are goto
Then you probably did not get my initial statement. goto decrease readability and maintainability in C/C++ Code and should be avoided unless you can justify it's usage. Additionally C++ does not define the instructions used on assembly level.
olli
yes
So Java does not support loops 🤷‍♂
Stefan
So Java does not support loops 🤷‍♂
the underlying jvm bytecodes are still jmp
Kat
Assembly just uses jmp for loops
Kat
So essentially all loops are gotos. But if the language you are using abstracts those gotos then use that abstraction 100% of the time. It's good practice.
olli
Nobody is questioning this. But a language such as C or C++ does not need goto statements to support loops
Avezy
cmp eax, 1 jz 0x04a876
Stefan
so how do you do state transition without goto
Stefan
abstract each state into one method?
Kat
But it abstracts those into something useful
Avezy
cmp eax, 1 jz 0x04a876
Jz is Basically jmp
Kat
Behind the abstraction, all languages are just doing jne, je, jmp, call, etc behind the scenes
olli
Behind the abstraction, all languages are just doing jne, je, jmp, call, etc behind the scenes
That's what the CPU is doing. Can you cite a paragraph where the standard actually defines this?
Kat
No, but that's just how it works.
Kat
A compiler just converts the syntax of a higher level language to machine code.
Kat
Any loop in a higher level language is essentially just conditional jumping
olli
A compiler just converts the syntax of a higher level language to machine code.
And that's why you don't need goto statements in you higher level language
Kat
I think we're a little confused here
Kat
Are you saying that a higher level language doesn't involve gotos or use them in any way or are you saying that you shouldn't use gotos in a higher level language?
olli
Are you saying that a higher level language doesn't involve gotos or use them in any way or are you saying that you shouldn't use gotos in a higher level language?
Again, you should not use goto statements in your c/c++ code unless you can justify it's usage. I am well aware loop, conditions ... are translated to jumps
Kat
I thought you were disagreeing about jumps being used behind the higher level code for some reason. My bad.
olli
I think we can agree on it, cant we? :)
Kat
Yeah lol
Stefan
http://wezfurlong.org/blog/2004/jul/goto-isnt-evil/
Stefan
also, without goto, you cannot effectively exit an inner loop without a flag
Talula
Without JMP computer wouldn't even work but... in C/C++ you don't need goto, I haven't written a sigle program in my life that needed goto in C/C++/C# (I don't even know if C# has goto).
olli
also, without goto, you cannot effectively exit an inner loop without a flag
This is (imo) a valid justification. The link basically said the same I did. If you have a valid reason to use it, then use it. Goto should however not be a replacement for your regular loops. (As it might be intended by the poll author)
yuuki
also, without goto, you cannot effectively exit an inner loop without a flag
Couldn't you just modularize that code? Use break or a function call where needed? Goto is depreciated imo. Cuz memory leaks.
Stefan
how does goto incur memory leak
yuuki
Good question. Although I'm not sure myself, I vaguely remember that it's not safe to use. Again, sorry for the mistake. My bad.
yuuki
No, goto is just not recommended to use cause of code structure.
Is that it?🤭 So it's alright? I've been living under a rock all these days..
MᏫᎻᎯᎷᎷᎬᎠ
Yo check this
MᏫᎻᎯᎷᎷᎬᎠ
https://www.facebook.com/groups/cppEnthusiasts/permalink/2151498654909443/
Liam
Soooooooo... fast..
MᏫᎻᎯᎷᎷᎬᎠ
Ew Facebook... no thanks.
You can go directly to the GitHub link
Kat
Oh cool, didn't read that far down, just saw Facebook and it set off my Zucc detector lol
MᏫᎻᎯᎷᎷᎬᎠ
Lol
klimi
Welcome
Anonymous
Hello
klimi
Hi
klimi
Welcome
klimi
Welcome
Dima
Welcome
LONGJMP
klimi
LONGJMP
Welcome
Dima
Welcome
SETJMP
klimi
SETJMP
Welcome
Daniele°
😂
klimi
😂
Shut up or welcome
Daniele°
setcontext(&ucp);
Daniele°
welcome
Liam
WTF……
Dima
setcontext(&ucp);
ucontext is deprecated by posix standarts
Dima
get rekt