Click here to Skip to main content
15,899,825 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: In defense of goto Pin
Mark_Wallace3-Jan-20 19:58
Mark_Wallace3-Jan-20 19:58 
GeneralRe: In defense of goto Pin
Greg Utas3-Jan-20 1:44
professionalGreg Utas3-Jan-20 1:44 
GeneralRe: In defense of goto Pin
H.Brydon4-Jan-20 16:21
professionalH.Brydon4-Jan-20 16:21 
GeneralRe: In defense of goto Pin
honey the codewitch4-Jan-20 17:00
mvahoney the codewitch4-Jan-20 17:00 
GeneralRe: In defense of goto Pin
Stefan_Lang5-Jan-20 22:22
Stefan_Lang5-Jan-20 22:22 
GeneralRe: In defense of goto Pin
honey the codewitch5-Jan-20 23:14
mvahoney the codewitch5-Jan-20 23:14 
GeneralRe: In defense of goto Pin
Stefan_Lang5-Jan-20 23:38
Stefan_Lang5-Jan-20 23:38 
GeneralRe: In defense of goto Pin
honey the codewitch6-Jan-20 6:43
mvahoney the codewitch6-Jan-20 6:43 
The issue here is state machines.

There are three ways to implement them:

1. Table driven
2. Goto driven
3. Using code synthesis to achieve while's, fors and ifs like you'd want.

There are a number of problems with #3, aside from code complexity.

State machines necessarily operate like spaghetti code and must jump freely.

Otherwise paths can't converge and you end up with a lot more code. Consider the following image: C# Keywords DFA[^]

That may seem extreme but it's not. This simply matches C# keywords. This exact state machine could be used in microsoft's production C# lexer (part of the csc.exe compiler) to do exactly that. It certainly would be if it was generated from the same keyword list.

See all the convergent paths? These are impossible to get to without gotos. The equivalent machine without convergent paths is about 5 times! the size. So the code will be, and the nests will be so deep it will be unintelligible anyway.

Edit: I mean yes, you could use inheritance but at that point all you're doing is presenting a facade over "gotos" but it's using the vtbl for it instead of explicit jumps.

It's still nasty when you have 500 states (not uncommon in a lexer) and the code would get huge.

A state is 3-5 lines of code generally in a lex routine. adding a class to that mix at least doubles that i'd think.

And yeah i found it matters. VS chokes on 1MB files when it comes to reporting the position of errors (sometimes)
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.


modified 6-Jan-20 13:10pm.

GeneralRe: In defense of goto Pin
Stefan_Lang7-Jan-20 22:03
Stefan_Lang7-Jan-20 22:03 
GeneralRe: In defense of goto Pin
honey the codewitch7-Jan-20 22:09
mvahoney the codewitch7-Jan-20 22:09 
GeneralRe: In defense of goto Pin
Stefan_Lang7-Jan-20 23:36
Stefan_Lang7-Jan-20 23:36 
GeneralRe: In defense of goto Pin
Stefan_Lang5-Jan-20 22:38
Stefan_Lang5-Jan-20 22:38 
GeneralRe: In defense of goto Pin
honey the codewitch5-Jan-20 23:15
mvahoney the codewitch5-Jan-20 23:15 
GeneralMini CCCs 160 Pin
Tim Deveaux2-Jan-20 17:30
Tim Deveaux2-Jan-20 17:30 
GeneralRe: Mini CCCs 160 Pin
OriginalGriff2-Jan-20 19:55
mveOriginalGriff2-Jan-20 19:55 
GeneralRe: Mini CCCs 160 - Done Pin
Tim Deveaux2-Jan-20 19:56
Tim Deveaux2-Jan-20 19:56 
Generalwe need to harness this talent for CodeProject ! Pin
BillWoodruff2-Jan-20 17:01
professionalBillWoodruff2-Jan-20 17:01 
GeneralRe: we need to harness this talent for CodeProject ! Pin
PIEBALDconsult2-Jan-20 18:20
mvePIEBALDconsult2-Jan-20 18:20 
GeneralRe: we need to harness this talent for CodeProject ! Pin
BillWoodruff3-Jan-20 1:12
professionalBillWoodruff3-Jan-20 1:12 
GeneralRe: we need to harness this talent for CodeProject ! Pin
Mark_Wallace2-Jan-20 23:50
Mark_Wallace2-Jan-20 23:50 
GeneralMy observations on parser generators Pin
honey the codewitch2-Jan-20 14:07
mvahoney the codewitch2-Jan-20 14:07 
GeneralRe: My observations on parser generators Pin
Greg Utas2-Jan-20 15:04
professionalGreg Utas2-Jan-20 15:04 
GeneralRe: My observations on parser generators Pin
honey the codewitch2-Jan-20 15:10
mvahoney the codewitch2-Jan-20 15:10 
GeneralRe: My observations on parser generators Pin
Greg Utas2-Jan-20 15:59
professionalGreg Utas2-Jan-20 15:59 
GeneralRe: My observations on parser generators Pin
honey the codewitch2-Jan-20 16:13
mvahoney the codewitch2-Jan-20 16:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   477 votes