Skip to content

Commit

Permalink
added corresponding snippets example.d, example.nim
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Jul 25, 2018
1 parent af2ad04 commit 2dc0a22
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
55 changes: 55 additions & 0 deletions example.d
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);
}
56 changes: 56 additions & 0 deletions example.nim
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

0 comments on commit 2dc0a22

Please sign in to comment.