Last active
September 13, 2018 06:37
-
-
Save LightSpeedC/e05197b38bd81641591d to your computer and use it in GitHub Desktop.
[JavaScript] goto 文の実装例 ref: https://qiita.com/LightSpeedC/items/32c1d1d3c466b04b59d1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printf("init\n"); | |
start: | |
printf("start\n"); | |
goto next; | |
skip: | |
printf("skip\n"); | |
next: | |
printf("next\n"); | |
printf("exit\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var target; | |
target: for (;;) switch (target) { | |
case undefined: | |
console.log('init'); | |
case 'start': | |
console.log('start'); | |
// goto next; | |
target = 'next'; | |
continue target; | |
case 'skip': | |
console.log('skip'); | |
case 'next': | |
console.log('next'); | |
default: | |
break target; | |
} | |
console.log('exit'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment