-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added corresponding snippets example.d, example.nim
- Loading branch information
1 parent
af2ad04
commit 2dc0a22
Showing
2 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
module foo; | ||
// line comment | ||
|
||
/+ | ||
block comment | ||
+/ | ||
|
||
import std.stdio; | ||
|
||
import std.path; | ||
static import std.path; | ||
|
||
public import std.file; | ||
|
||
import std.path : expandTilde; | ||
|
||
static int g1 = 1; | ||
int g2 = 1; | ||
|
||
/// documentation comment | ||
void test1(){ | ||
writeln("foo"); | ||
writeln("foo", 2); | ||
auto a1 = 1; | ||
int a2 = 1; | ||
const a3 = 1; | ||
enum a4 = 1; | ||
} | ||
|
||
void fun(int a){ | ||
} | ||
|
||
int fun2(int a){ | ||
return a*a; | ||
} | ||
|
||
void fun3(T)(T a){ | ||
} | ||
|
||
void test2(){ | ||
test1; | ||
test1(); | ||
|
||
fun(2); | ||
1.fun; | ||
|
||
const a = fun2(1) | ||
fun2(1) | ||
|
||
fun3(1.0) | ||
} | ||
|
||
void main(string[]args){ | ||
writeln(args); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#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 | ||
|