Click here to Skip to main content
14,580,516 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
MemberMark_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
mveStefan_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
mveStefan_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
mveStefan_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
mveStefan_Lang7-Jan-20 23:36 
GeneralRe: In defense of goto Pin
Stefan_Lang5-Jan-20 22:38
mveStefan_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
MemberTim 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
MemberTim Deveaux2-Jan-20 19:56 
Generalwe need to harness this talent for CodeProject ! Pin
BillWoodruff2-Jan-20 17:01
mveBillWoodruff2-Jan-20 17:01 
GeneralRe: we need to harness this talent for CodeProject ! Pin
PIEBALDconsult2-Jan-20 18:20
professionalPIEBALDconsult2-Jan-20 18:20 
GeneralRe: we need to harness this talent for CodeProject ! Pin
BillWoodruff3-Jan-20 1:12
mveBillWoodruff3-Jan-20 1:12 
GeneralRe: we need to harness this talent for CodeProject ! Pin
Mark_Wallace2-Jan-20 23:50
MemberMark_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.