On 2017-12-29 23:12, bartc wrote:
On 29/12/2017 21:55, Lawrence D’Oliveiro wrote:
On Saturday, December 30, 2017 at 9:03:50 AM UTC+13, bartc wrote:
Why most newer, higher level languages don't, I don't know. Perhaps
because the people who design them want to make programming harder?

I don’t use gotos in C code. Why should it be “harder” in a higher-level 
language?


Good for you.

Looking at 14 million lines of Linux kernel sources, which are in C,
over 100,000 of them use 'goto'. About one every 120 lines.

My own low level sources use about one goto every 400 lines. It's hardly
a lot. If one is used, it's because it was handy to use it, until such
time as it can be replaced with proper logic. But such logic will
usually be more convoluted.

BTW, looking at 220,000 lines of CPython sources, in C (an old
distribution I had to hand), there are 2600 gotos, about one every 85
lines. And those are the ones are directly visible as gotos, and not
hidden behind macros.

I understand that on Linux, the CPython dispatcher makes use of label
pointers, using 'goto *opcode_targets[*next_instr++]' to do a faster
byte-code dispatch than using switch.

You I guess would have written it without that, and we'd all have to
suffer 10% slower speed (or whatever) for your principles. That's
assuming you could have got rid of the other 2600 gotos as well.

I too use goto in C code, principally to go to clean-up code after checking the result of a call.

In Python, on the other hand, I have automatic garbage collection, exceptions, etc.

It's OK for code that's close to the metal, but in high-level code? No.

Python has managed for >25 years without it, and I've yet to see a convincing use-case.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to