Click here to Skip to main content
15,891,184 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
kalberts2-Jan-20 22:43
kalberts2-Jan-20 22:43 
GeneralRe: In defense of goto Pin
honey the codewitch2-Jan-20 22:50
mvahoney the codewitch2-Jan-20 22:50 
GeneralRe: In defense of goto Pin
jsc422-Jan-20 23:15
professionaljsc422-Jan-20 23:15 
GeneralRe: In defense of goto Pin
honey the codewitch3-Jan-20 5:05
mvahoney the codewitch3-Jan-20 5:05 
GeneralRe: In defense of goto Pin
kalberts3-Jan-20 0:14
kalberts3-Jan-20 0:14 
GeneralRe: In defense of goto Pin
honey the codewitch3-Jan-20 3:56
mvahoney the codewitch3-Jan-20 3:56 
GeneralRe: In defense of goto Pin
kalberts3-Jan-20 5:16
kalberts3-Jan-20 5:16 
GeneralRe: In defense of goto Pin
honey the codewitch3-Jan-20 5:23
mvahoney the codewitch3-Jan-20 5:23 
using an FSM inside those procedures is only really needed for k>1. To explain: Here's what a typical procedure looks like - the comparisons are only 1 deep. That's why k=1. Watch:

C#
internal static ParseNode ParseIdentifier(ParserContext context) {
            int line__ = context.Line;
            int column__ = context.Column;
            long position__ = context.Position;
            // Identifier -> verbatimIdentifier
            if (((ExpressionParser.verbatimIdentifier == context.SymbolId) 
                        && ExpressionParser.WhereIdentifier(context.GetLookAhead(true)))) {
                ParseNode[] children = new ParseNode[1];
                if ((false 
                            == (ExpressionParser.verbatimIdentifier == context.SymbolId))) {
                    context.Error("Expecting verbatimIdentifier at line {0}, column {1}, position {2}", context.Line, context.Column, context.Position);
                }
                children[0] = new ParseNode(ExpressionParser.verbatimIdentifier, "verbatimIdentifier", context.Value, context.Line, context.Column, context.Position);
                context.Advance();
                return new ParseNode(ExpressionParser.Identifier, "Identifier", children, line__, column__, position__);
            }
            // Identifier -> identifier
            if (((ExpressionParser.identifier2 == context.SymbolId) 
                        && ExpressionParser.WhereIdentifier(context.GetLookAhead(true)))) {
                ParseNode[] children = new ParseNode[1];
                if ((false 
                            == (ExpressionParser.identifier2 == context.SymbolId))) {
                    context.Error("Expecting identifier at line {0}, column {1}, position {2}", context.Line, context.Column, context.Position);
                }
                children[0] = new ParseNode(ExpressionParser.identifier2, "identifier", context.Value, context.Line, context.Column, context.Position);
                context.Advance();
                return new ParseNode(ExpressionParser.Identifier, "Identifier", children, line__, column__, position__);
            }
            throw new SyntaxException("Expecting verbatimIdentifier or identifier", line__, column__, position__);
        }


Sorry for posting so much code, but i wanted it to be true to what I'm generating.

Notice how the if statements are only one level deep. (except for the where constraint - WhereIdentifier but that's an aside right now - it's a separate conversation)

If i needed more than that, I'd certainly use an FSM inside this procedure. I hear you and in fact it's how I plan to do it. My in defense of gotos post was about using gotos as an FSM to do what you're talking about here. Using whiles to do it complicates the generation and explodes the output code size, requiring other compression techniques which make the code more, not less confusing. I prefer to make my state machines renderable to graphviz and then simply label each of the goto labels after the state in graphviz it represents. It's a map to the state machine. It makes it clear. That's my only contention in terms of how to go about it. I prefer the goto approach because i can make it followable to humans. I cannot do so with table compression techniques.
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.

GeneralRe: In defense of goto Pin
glennPattonWork32-Jan-20 23:13
professionalglennPattonWork32-Jan-20 23:13 
GeneralRe: In defense of goto Pin
kalberts3-Jan-20 0:35
kalberts3-Jan-20 0:35 
GeneralRe: In defense of goto Pin
glennPattonWork33-Jan-20 0:41
professionalglennPattonWork33-Jan-20 0:41 
GeneralRe: In defense of goto Pin
kalberts3-Jan-20 1:32
kalberts3-Jan-20 1:32 
GeneralRe: In defense of goto Pin
Rick York3-Jan-20 5:02
mveRick York3-Jan-20 5:02 
GeneralRe: In defense of goto Pin
Mark_Wallace2-Jan-20 23:48
Mark_Wallace2-Jan-20 23:48 
GeneralRe: In defense of goto Pin
honey the codewitch3-Jan-20 4:01
mvahoney the codewitch3-Jan-20 4:01 
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 
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 

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.