diff --git a/Nim-for-C-programmers.md b/Nim-for-C-programmers.md index 17f0aa9..ffafe4c 100644 --- a/Nim-for-C-programmers.md +++ b/Nim-for-C-programmers.md @@ -29,7 +29,7 @@ Types | Static | Static Dependent types | No | Partial support Generics | No (Templates w/ C++) | Yes int8/16/32/64 types | Yes | Yes -Unsigned ints | Yes (by default) | Yes (not by default) +Unsigned ints | Yes (by default) | Yes Arrays | Yes | Yes Bounds-checking | No | Yes Type inference | No (some w/ C++11) | Yes (extensive support) @@ -71,7 +71,7 @@ int main() { **Nim:** -```Nimrod +```nim proc foobar(z: array[0..3, int]) = z[5] = 5 # Error: Cannot assign to z echo z[5] # Error: Index out of bounds. @@ -104,7 +104,7 @@ You can call a proc on objects with the ```anObject.foobar()```, but you can do Nim does not have an implicit _this_/_self_. -It is possible to implement object-orientation features from other languages (like C++,Java,etc. or Smalltalk,Obj-C,Ruby,etc.) through libraries, thanks to the extensive meta-programming features of Nim. These are at the moment mostly work-in-progress. +It is possible to implement object-orientation features from other languages (like C++, Java, etc. or Smalltalk, Obj-C, Ruby, etc.) through libraries, thanks to the extensive meta-programming features of Nim. These are at the moment mostly work-in-progress. ### Structs - Tuples and Objects @@ -302,8 +302,7 @@ proc bar(): int = proc baz(x: int): int = x*2 -proc foobar(x: var int): - int = +proc foobar(x: var int): int = inc(x) result = x*2 @@ -340,8 +339,8 @@ void foobar(person_t *a) {
-proc foobar(a: ref TPerson) = - var b: TPerson +proc foobar(a: ref Person) = + var b: Person b = a[] b.name = "Bob" a[] = b @@ -367,7 +366,7 @@ printf("%d, %d, %p\n", x, y, p);
-var d: float = 3.1415926 +var d = 3.1415926 var i = d.int d = i.float echo i, " ",d