Updated Nimrod for C programmers (markdown)

This commit is contained in:
Audun Wilhelmsen 2013-12-26 15:20:35 -08:00
parent f8c459f21b
commit 3565b10410
1 changed files with 2 additions and 2 deletions

View File

@ -34,7 +34,7 @@ The other important thing to know is that while C uses a separate language to do
In C an array is more or less syntactic sugar for pointers. In Nimrod, arrays are much more strict and safe to use. They are pass-by-value (meaning they're copied at assignment). When passing an array to a proc in Nimrod, the argument is a read-only reference, meaning it can't be assigned to. Take the following example:
**C:**
```C
```c
void foobar(int z[4]) {
z[5] = 5;
printf("%d\n",z[5]);
@ -48,7 +48,7 @@ int main() {
```
**Nimrod:**
```Nimrod
```nimrod
proc foobar(z: array[0..3, int]) =
z[5] = 5 # Error: Cannot assign to z
echo z[5] # Error: Index out of bounds.