-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathexample.nim
More file actions
56 lines (39 loc) · 730 Bytes
/
example.nim
File metadata and controls
56 lines (39 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#TODO: expand this along with example.d
# line comment
#[
block comment
]#
import std/ospaths
from std/ospaths import nil
import std/file
export file
from std/ospaths import expandTilde
var g1 = 1
var g2 {.threadvar.}: int # TODO: initialize to 1
proc test1()=
## documentation comment
echo "foo"
echo "foo", 2
var a1 = 1
var a2: int = 1 #NOTE: Nim's == D's ptrdiff_t
let a3 = 1
const a4 = 1
proc fun(a:int) =
discard
proc fun2(a:int): auto=
# or: a*a
# or: result = a*a
return a*a
proc fun3[T](a:T) =
discard
proc test2()=
# test1 # doesn't work, by design
test1()
# or: fun 2
fun(2)
1.fun
let a = fun2(1)
discard fun2(1)
fun3(1.0)
when isMainModule:
# echo args # TODO