Click here to Skip to main content
15,904,494 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: for those of you purists that don't like break, continue and goto Pin
Jörgen Andersson14-Sep-19 4:18
professionalJörgen Andersson14-Sep-19 4:18 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
honey the codewitch14-Sep-19 4:22
mvahoney the codewitch14-Sep-19 4:22 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
Jörgen Andersson14-Sep-19 4:49
professionalJörgen Andersson14-Sep-19 4:49 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
honey the codewitch14-Sep-19 5:01
mvahoney the codewitch14-Sep-19 5:01 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
OriginalGriff14-Sep-19 4:07
mveOriginalGriff14-Sep-19 4:07 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
honey the codewitch14-Sep-19 4:09
mvahoney the codewitch14-Sep-19 4:09 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
Nand3214-Sep-19 4:17
Nand3214-Sep-19 4:17 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
honey the codewitch14-Sep-19 4:20
mvahoney the codewitch14-Sep-19 4:20 
ugh, VB. I use goto in some of my code.

Perfectly acceptable place to use GOTO - generated state machine code:

C#
public static bool AcceptsByte(Grimoire.ParseContext pc)
{
	pc.EnsureStarted();
	if (-1 == pc.Current) return false;
	if ((48 == pc.Current))
	{
		pc.Advance();
		goto AcceptsByte_s1;
	}
	if ((49 == pc.Current))
	{
		pc.Advance();
		goto AcceptsByte_s2;
	}
	if ((50 == pc.Current))
	{
		pc.Advance();
		goto AcceptsByte_s4;
	}
	if ((51 <= pc.Current && 57 >= pc.Current))
	{
		pc.Advance();
		goto AcceptsByte_s3;
	}
	return false;
AcceptsByte_s1:
	if (-1 == pc.Current) return true;
	return -1 == pc.Advance();
AcceptsByte_s2:
	if (-1 == pc.Current) return true;
	if ((48 <= pc.Current && 57 >= pc.Current))
	{
		pc.Advance();
		goto AcceptsByte_s3;
	}
	return -1 == pc.Advance();
AcceptsByte_s3:
	if (-1 == pc.Current) return true;
	if ((48 <= pc.Current && 57 >= pc.Current))
	{
		pc.Advance();
		goto AcceptsByte_s1;
	}
	return -1 == pc.Advance();
AcceptsByte_s4:
	if (-1 == pc.Current) return true;
	if ((48 <= pc.Current && 52 >= pc.Current))
	{
		pc.Advance();
		goto AcceptsByte_s3;
	}
	if ((53 == pc.Current))
	{
		pc.Advance();
		goto AcceptsByte_s5;
	}
	if ((54 <= pc.Current && 57 >= pc.Current))
	{
		pc.Advance();
		goto AcceptsByte_s1;
	}
	return -1 == pc.Advance();
AcceptsByte_s5:
	if (-1 == pc.Current) return true;
	if ((48 <= pc.Current && 52 >= pc.Current))
	{
		pc.Advance();
		goto AcceptsByte_s1;
	}
	return -1 == pc.Advance();
}


but then I wouldn't write that code by hand. Too error prone.
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: for those of you purists that don't like break, continue and goto Pin
Nand3214-Sep-19 4:26
Nand3214-Sep-19 4:26 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
honey the codewitch14-Sep-19 4:28
mvahoney the codewitch14-Sep-19 4:28 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
John Brett15-Sep-19 21:21
John Brett15-Sep-19 21:21 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
Andrew Leeder15-Sep-19 23:29
Andrew Leeder15-Sep-19 23:29 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
honey the codewitch16-Sep-19 0:29
mvahoney the codewitch16-Sep-19 0:29 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
John Brett16-Sep-19 0:35
John Brett16-Sep-19 0:35 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
honey the codewitch16-Sep-19 0:39
mvahoney the codewitch16-Sep-19 0:39 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
lopatir14-Sep-19 4:14
lopatir14-Sep-19 4:14 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
honey the codewitch14-Sep-19 4:17
mvahoney the codewitch14-Sep-19 4:17 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
kalberts15-Sep-19 23:13
kalberts15-Sep-19 23:13 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
GuyThiebaut14-Sep-19 4:11
professionalGuyThiebaut14-Sep-19 4:11 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
honey the codewitch14-Sep-19 4:15
mvahoney the codewitch14-Sep-19 4:15 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
lopatir14-Sep-19 4:22
lopatir14-Sep-19 4:22 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
honey the codewitch14-Sep-19 4:24
mvahoney the codewitch14-Sep-19 4:24 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
GuyThiebaut14-Sep-19 4:24
professionalGuyThiebaut14-Sep-19 4:24 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
honey the codewitch14-Sep-19 4:26
mvahoney the codewitch14-Sep-19 4:26 
GeneralRe: for those of you purists that don't like break, continue and goto Pin
Nand3214-Sep-19 4:25
Nand3214-Sep-19 4:25 

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.