diff --git a/tools/website.tmpl b/tools/website.tmpl index e1fdf67012..6dce93d147 100644 --- a/tools/website.tmpl +++ b/tools/website.tmpl @@ -7,7 +7,6 @@
+parallel: + var i = 0 + while i <= a.high: + spawn f(a[i]) + spawn f(a[i+1]) + # ERROR: cannot prove a[i] is disjoint from a[i+1] + # BUT: replace 'i += 1' with 'i += 2' and the code compiles! + i += 1 ++
# compute average line length ++# compute average line length var sum = 0 count = 0 @@ -68,7 +82,8 @@ echo("Average line length: ",
# create and greet someone ++# create and greet someone type Person = object name: string age: int @@ -81,58 +96,43 @@ echo("Average line length: ", p.greet() # or greet(p)
-parallel: - var i = 0 - while i <= a.high: - spawn f(a[i]) - spawn f(a[i+1]) - # ERROR: cannot prove a[i] is disjoint from a[i+1] - # BUT: replace 'i += 1' with 'i += 2' and the code compiles! - i += 1 -
-proc unsafeScanf(f: File; s: cstring) - {.importc: "fscanf", - header: "<stdio.h>", varargs.} - -var x: cint -unsafeScanf(stdin, "%d", addr x) -
+# declare a C procedure.. +proc unsafeScanf(f: File, s: cstring) + {.varargs, + importc: "fscanf", + header: "<stdio.h>".} + +# ..and use it... +var x: cint +stdin.unsafeScanf("%d", addr x) ++
Compile and run with:
$ nim c -r example.nim
+# a simple web server import jester, asyncdispatch, htmlgen -routes: - get "/": - resp h1("Hello world") +# using jester commands +routes: + get "/": + resp h1("Hello world") runForever() -
-Compile and run with:
-nim c -r example.nim
-View at: localhost:5000
-
View in browser at:
localhost:5000