Updated Nim for C programmers (markdown)

This commit is contained in:
Daniil Yarancev 2017-10-16 15:39:39 +03:00
parent 719d864ea7
commit 8c8a8ccd61
1 changed files with 7 additions and 8 deletions

View File

@ -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.
@ -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
</pre>
@ -340,8 +339,8 @@ void foobar(person_t *a) {
</td>
<td>
<pre>
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);
</td>
<td>
<pre>
var d: float = 3.1415926
var d = 3.1415926
var i = d.int
d = i.float
echo i, " ",d