nim-goto
所属分类:编程语言基础
开发工具:Nim
文件大小:0KB
下载次数:0
上传日期:2024-04-04 03:27:29
上 传 者:
sh-1993
说明: Nim编程语言的goto语句。
(The goto statement of the Nim programming language.)
文件列表:
src/
tests/
LICENSE
goto.nimble
# Nim GoTo
This implements the `goto` statement of the Nim programming language.
The word `label` can be used to create a label, while `goto` or `jmp` can be used to jump to it.
### Example
``` nim
import goto
proc main =
var i = 1
label L1:
echo i
i += 1
if i < 100:
goto L1
main()
```
The word `jmp` can be used instead of `goto`. Their semantics are same.
``` nim
import goto
proc main =
var i = 1
label L1:
echo i
inc i
if i < 100:
jmp L1
main()
```
### How it works
As we know, Nim code can be compiled to C. Although Nim itself doesn't have `goto`, we can still put a label in the generated C code.
### Note
+ As this emits C code, it can only be used with the C-like backends.
+ The Nim compiler also use labels in the C code. So please never use a label with one or more underscores (`_`) in the name, or the result is unpredictable.
+ This is unstable.
近期下载者:
相关文件:
收藏者: