From 2bd2af6e1c5c57ac3f737a6b8d2a233ad027392a Mon Sep 17 00:00:00 2001 From: Flaviu Tamas Date: Thu, 11 Dec 2014 17:04:49 -0500 Subject: [PATCH] Rename to Nim --- README.md | 4 ++-- content/arrays.md | 4 ++-- content/bitsets.md | 2 +- content/block.md | 2 +- content/case.md | 6 +++--- content/for_iterators.md | 12 +++++------ content/getting_started.md | 22 ++++++++++----------- content/hello_world.md | 4 ++-- content/if_else_while.md | 4 ++-- content/index.md | 8 ++++---- content/oop.md | 2 +- content/oop_macro.md | 6 +++--- content/opengl/triangle.md | 4 ++-- content/primitives.md | 4 ++-- content/procs.md | 4 ++-- content/procvars.md | 4 ++-- content/strings.md | 2 +- content/types/enums.md | 4 ++-- content/types/objects.md | 2 +- content/varargs.md | 4 ++-- content/variables.md | 4 ++-- content/variables/type_casting_inference.md | 6 +++--- layouts/default.html | 6 +++--- testexamples.nim | 6 +++--- wercker.yml | 2 +- 25 files changed, 64 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 132a1ed..ae6822a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![wercker status](https://app.wercker.com/status/389477226e537a45143ea91336dca281/m "wercker status")](https://app.wercker.com/project/bykey/389477226e537a45143ea91336dca281) -This repo contains the sources for the Nimrod by Example book. +This repo contains the sources for the Nim by Example book. -If you'd like, use `nanoc` to build. However, its easiest to simply write things and wait for the webpage at http://nimrod-by-example.github.io/ to update, courtesy of the people at wercker. +If you'd like, use `nanoc` to build. However, its easiest to simply write things and wait for the webpage at http://nim-by-example.github.io/ to update, courtesy of the people at wercker. diff --git a/content/arrays.md b/content/arrays.md index 3c560ac..e401253 100644 --- a/content/arrays.md +++ b/content/arrays.md @@ -4,7 +4,7 @@ title: Arrays # Arrays -The arrays in Nimrod are like classic C arrays, their size is specified at compile-time and cannot given or changed at runtime. +The arrays in Nim are like classic C arrays, their size is specified at compile-time and cannot given or changed at runtime. ``` nimrod type @@ -57,7 +57,7 @@ echo mat1 + mat2 ``` ``` console -$ nimrod c -r matrix.nim +$ nim c -r matrix.nim 1, 1, 1, 1, diff --git a/content/bitsets.md b/content/bitsets.md index 1ceb446..db7f9e9 100644 --- a/content/bitsets.md +++ b/content/bitsets.md @@ -4,7 +4,7 @@ title: Bitsets # Bitsets -Nimrod comes with a built in way to build a set of ordinal types. In order for a type to be usable in a bitset, it must be an ordinal and <<\texttt{high(T)} < 2^{16}>>. For sets of non-ordinal types, see the [sets module](http://nimrod-lang.org/sets.html), which contains hashsets. +Nim comes with a built in way to build a set of ordinal types. In order for a type to be usable in a bitset, it must be an ordinal and <<\texttt{high(T)} < 2^{16}>>. For sets of non-ordinal types, see the [sets module](http://nim-lang.org/sets.html), which contains hashsets. However, best practice is to keep bitset size significantly smaller since each possible element in the set consumes one bit, therefore a bitset of <<2^{16}>> elements will consume 64KiB. diff --git a/content/block.md b/content/block.md index 3e99fbf..988ca97 100644 --- a/content/block.md +++ b/content/block.md @@ -21,7 +21,7 @@ block: let b = "3" # shadowing is probably a dumb idea ``` -Parentheses can be used as an expression, but they do not provide end of statement inference, so it is necessary to place semicolons yourself. An interesting and unexpected side effect of this syntax is that Nimrod is suitable even for brace purists! +Parentheses can be used as an expression, but they do not provide end of statement inference, so it is necessary to place semicolons yourself. An interesting and unexpected side effect of this syntax is that Nim is suitable even for brace purists! ``` nimrod proc square(inSeq: seq[float]): seq[float] = ( diff --git a/content/case.md b/content/case.md index f8d7a87..fc64a76 100644 --- a/content/case.md +++ b/content/case.md @@ -3,7 +3,7 @@ title: Case Statements --- # Case Statements -Nimrod also supports case statements, which are like switches in other languages. There are several things to note here: +Nim also supports case statements, which are like switches in other languages. There are several things to note here: * You can use strings in the switch statement * Sets and ranges of ordinal types are also usable @@ -44,7 +44,7 @@ echo positiveOrNegative(-1) ``` ``` console -$ nimrod c -r ./case_stmts.nim +$ nim c -r ./case_stmts.nim C Consonant negative @@ -61,6 +61,6 @@ case (x and 3) + 7: of 10: echo "D" ``` ``` console -$ nimrod c -r ./case_stmts_1.nim +$ nim c -r ./case_stmts_1.nim C ``` diff --git a/content/for_iterators.md b/content/for_iterators.md index 956e1bf..647e856 100644 --- a/content/for_iterators.md +++ b/content/for_iterators.md @@ -3,11 +3,11 @@ title: For Loops & Iterators --- # For Loops & Iterators -Nimrod has first class iterators and syntax to use them, for loops. The `continue` and `break` keywords also work inside of for loops. There are two kinds of iterator, and two special methods that for loops work with. +Nim has first class iterators and syntax to use them, for loops. The `continue` and `break` keywords also work inside of for loops. There are two kinds of iterator, and two special methods that for loops work with. ## `items` and `pair` -When iterating over an object with one item, Nimrod will call an iterator called `items` with the first parameter the type you want to iterate over. The same thing happens when iterating with two items, but in that case, the `pairs` iterator is called. +When iterating over an object with one item, Nim will call an iterator called `items` with the first parameter the type you want to iterate over. The same thing happens when iterating with two items, but in that case, the `pairs` iterator is called. ``` nimrod type @@ -29,7 +29,7 @@ for i, c in TRange(low: 1, high: 3): echo c ``` ``` console -$ nimrod c -r items_pair.nim +$ nim c -r items_pair.nim b c d @@ -50,7 +50,7 @@ for i in 0...5: echo i ``` ``` console -$ nimrod c -r operatoriterator.nim +$ nim c -r operatoriterator.nim 0 1 2 @@ -73,7 +73,7 @@ for i in countTo(5): echo i ``` ```console -$ nimrod c -r ./inline_iter.nim +$ nim c -r ./inline_iter.nim 0 1 2 @@ -118,7 +118,7 @@ for i in countTo9(): echo output ``` ```console -$ nimrod c -r ./closure_iter.nim +$ nim c -r ./closure_iter.nim 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0123456789 diff --git a/content/getting_started.md b/content/getting_started.md index 6f941c4..475bfff 100644 --- a/content/getting_started.md +++ b/content/getting_started.md @@ -2,10 +2,10 @@ title: Getting Started --- # Getting Started -When installing Nimrod, you have two options: downloading a copy directly from git, or downloading a prepackaged distribution from the website +When installing Nim, you have two options: downloading a copy directly from git, or downloading a prepackaged distribution from the website -## Downloading a Nimrod Distribution -To get started with Nimrod, head over to the [downloads page](http://nimrod-lang.org/download.html) and download the version you'd like. +## Downloading a Nim Distribution +To get started with Nim, head over to the [downloads page](http://nim-lang.org/download.html) and download the version you'd like. The Windows distribution comes with the MinGW compiler, which is recommended, but if you'd like to use your own compiler, download the version without MinGW. @@ -13,23 +13,23 @@ On Mac and Linux, it is recommended to use either GCC or Clang. | | i386 | amd64 | | -- | ---- | ----- | -| Windows | [Download](http://nimrod-lang.org/download/nimrod_0.9.4_windows_i386_full.zip) ([w/o MinGW](http://nimrod-lang.org/download/nimrod_0.9.4_windows_i386_slim.zip))| [Download](http://nimrod-lang.org/download/nimrod_0.9.4_windows_amd64_full.zip) ([w/o MinGW](http://nimrod-lang.org/download/nimrod_0.9.4_windows_amd64_slim.zip)) | -| Mac | NA | [Download](http://nimrod-lang.org/download/nimrod_0.9.4_macosx_amd64.zip) | -| Linux | [Download](http://nimrod-lang.org/download/nimrod_0.9.4_linux_i386.tar.gz) | [Download](http://nimrod-lang.org/download/nimrod_0.9.4_linux_amd64.tar.gz) | +| Windows | [Download](http://nim-lang.org/download/nim_0.9.4_windows_i386_full.zip) ([w/o MinGW](http://nim-lang.org/download/nim_0.9.4_windows_i386_slim.zip))| [Download](http://nim-lang.org/download/nim_0.9.4_windows_amd64_full.zip) ([w/o MinGW](http://nim-lang.org/download/nim_0.9.4_windows_amd64_slim.zip)) | +| Mac | NA | [Download](http://nim-lang.org/download/nim_0.9.4_macosx_amd64.zip) | +| Linux | [Download](http://nim-lang.org/download/nim_0.9.4_linux_i386.tar.gz) | [Download](http://nim-lang.org/download/nim_0.9.4_linux_amd64.tar.gz) | Once you have downloaded the appropriate distribution and extracted the files somewhere convenient, feel free to place the `bin` directory in the path for easier access. ## Downloading from Git -To install Nimrod from git, ensure that you have gcc installed on Windows, Linux, and BSDs and clang on Mac. Afterwards, run the following series of commands to download and bootstrap Nimrod: +To install Nim from git, ensure that you have gcc installed on Windows, Linux, and BSDs and clang on Mac. Afterwards, run the following series of commands to download and bootstrap Nim: ```console -$ git clone -b master git://github.com/Araq/Nimrod.git -$ cd Nimrod -$ git clone --depth 1 git://github.com/nimrod-code/csources +$ git clone -b master git://github.com/Araq/Nim.git +$ cd Nim +$ git clone --depth 1 git://github.com/nim-code/csources $ cd csources $ sh build.sh # Replace with build.bat on windows $ cd .. -$ bin/nimrod c koch +$ bin/nim c koch $ ./koch boot -d:release ``` diff --git a/content/hello_world.md b/content/hello_world.md index 372aa0e..2d938a4 100644 --- a/content/hello_world.md +++ b/content/hello_world.md @@ -12,13 +12,13 @@ echo "Hello World" Save this text as `helloworld.nim`. To compile and execute the program, the following command should be run ``` console -$ nimrod c -r --verbosity:0 helloworld.nim +$ nim c -r --verbosity:0 helloworld.nim Hello World ``` The command has several elements: -* `c` is an alias for `compile`, which compiles the Nimrod sources into C and then invokes the C compiler on them +* `c` is an alias for `compile`, which compiles the Nim sources into C and then invokes the C compiler on them * `-r` is an alias for `--run`, which runs the program * `--verbosity:0` makes the compiler only output essential messages, since by default it also outputs some debugging messages. From now on, we assume that `--verbosity:0` is set * `./helloworld.nim` is the path to the source you want to compile diff --git a/content/if_else_while.md b/content/if_else_while.md index 044f041..026d43a 100644 --- a/content/if_else_while.md +++ b/content/if_else_while.md @@ -4,13 +4,13 @@ title: If, Else, While # If, Else, While -Nimrod has many different control flow constructs, including the standard `if`s, `else`s, and `while`s. However, Nimrod does not use an `else if` construct like many languages, it uses a more condensed `elif`. +Nim has many different control flow constructs, including the standard `if`s, `else`s, and `while`s. However, Nim does not use an `else if` construct like many languages, it uses a more condensed `elif`. When inside a loop, `continue` can be used to skip the rest of the loop body and to begin the next iteration; `break` can be used to immediately leave the loop body. Along with [its other uses](/block/), the `block` statement can be used to create a label so that it's possible to break out of nested loops. -``` nimrod +``` nim import strutils, math randomize() diff --git a/content/index.md b/content/index.md index ed86764..9b3078d 100644 --- a/content/index.md +++ b/content/index.md @@ -2,15 +2,15 @@ title: Main --- -# Nimrod by Example +# Nim by Example -[Nimrod] is a powerful statically typed language that allows the programmer expressiveness without compromising run-time performance. As a general purpose programming language, it gives the same sort of power and performance as C++, but in a nicer package and with even more powerful tools! +[Nim] is a powerful statically typed language that allows the programmer expressiveness without compromising run-time performance. As a general purpose programming language, it gives the same sort of power and performance as C++, but in a nicer package and with even more powerful tools! -[Nimrod]: http://nimrod-lang.org/ +[Nim]: http://nim-lang.org/ Getting started? Head over to the [installation instructions](/getting_started/)! -``` nimrod +``` nim import tables, strutils var wordFrequencies = initCountTable[string]() diff --git a/content/oop.md b/content/oop.md index 4274632..4a210b4 100644 --- a/content/oop.md +++ b/content/oop.md @@ -32,7 +32,7 @@ for a in animals: echo a.ageHumanYrs() ``` ``` console -$ nimrod c -r oop.nim +$ nim c -r oop.nim woof 70 meow diff --git a/content/oop_macro.md b/content/oop_macro.md index 0566d3b..e784016 100644 --- a/content/oop_macro.md +++ b/content/oop_macro.md @@ -4,7 +4,7 @@ title: OOP Macro # OOP Macro -This is the code that we currently must write to use OOP in Nimrod: +This is the code that we currently must write to use OOP in Nim: ```nimrod type Animal = ref object of TObject @@ -47,7 +47,7 @@ macro class*(head: expr, body: stmt): stmt {.immediate.} = # The macro is immediate so that it doesn't # resolve identifiers passed to it - var typeName, baseName: PNimrodNode + var typeName, baseName: PNimNode if head.kind == NnkIdent: # `head` is expression `typeName` @@ -222,7 +222,7 @@ for a in animals: echo a.age_human_yrs() ``` ``` console -$ nimrod c -r oopmacro.nim +$ nim c -r oopmacro.nim woof 70 meow diff --git a/content/opengl/triangle.md b/content/opengl/triangle.md index f0863c4..5da0d17 100644 --- a/content/opengl/triangle.md +++ b/content/opengl/triangle.md @@ -7,9 +7,9 @@ The following code depends on the ``opengl`` and ``nim-glfw`` packages which can be installed via babel by executing ``babel install opengl@#head nim-glfw@#head``. You will need the GLFW DLL in order to run this on Windows. -![Triangle Windows](https://nimrod-by-example.github.io/images/triangle.png) +![Triangle Windows](https://nim-by-example.github.io/images/triangle.png) -One thing to keep in mind when writing OpenGL code in Nimrod is that ``float`` +One thing to keep in mind when writing OpenGL code in Nim is that ``float`` is actually ``float64``. But vertices must be ``float32`` so you must explicitly specify that by casting or using ``'f32`` as is done in the example. diff --git a/content/primitives.md b/content/primitives.md index ab9ac7f..0148281 100644 --- a/content/primitives.md +++ b/content/primitives.md @@ -3,7 +3,7 @@ title: Primitives --- # Primitives -Nimrod has several primitive types: +Nim has several primitive types: * signed integers: `int8`, `int16`, `int32`, `int64`, and `int`, where `int` is the same size as a pointer * unsigned integers are similar with `u` prepended to the type @@ -31,7 +31,7 @@ let echo 4/2 ``` ``` console -$ nimrod c -r numbers2.nim +$ nim c -r numbers2.nim 2.0 ``` Another difference that may be surprising is that the `/` operator returns a floating point result, even when the operands are integers. If integer division is needed, the `div` operator should be used. diff --git a/content/procs.md b/content/procs.md index 6cfa3e0..9e3eb9f 100644 --- a/content/procs.md +++ b/content/procs.md @@ -3,7 +3,7 @@ title: Procs --- # Procs -Procedures in Nimrod are declared using `proc` and require that their parameter and return types be annotated. After the types and parameters, an `=` is used to denote the start of the function body. Another thing to note is that procedures have uniform function call syntax, which means that they can called as both `foo(a, b)` or `a.foo(b)`. +Procedures in Nim are declared using `proc` and require that their parameter and return types be annotated. After the types and parameters, an `=` is used to denote the start of the function body. Another thing to note is that procedures have uniform function call syntax, which means that they can called as both `foo(a, b)` or `a.foo(b)`. ``` nimrod proc fibonacci(n: int): int = @@ -30,7 +30,7 @@ echo bar() # will not compile ## Side effect analyses -Nimrod provides support for functional programming and so includes the `{.noSideEffect.}` pragma, which statically ensures there are no side effects. +Nim provides support for functional programming and so includes the `{.noSideEffect.}` pragma, which statically ensures there are no side effects. ``` nimrod proc sum(x, y: int): int {. noSideEffect .} = diff --git a/content/procvars.md b/content/procvars.md index 3f92528..53c6ad1 100644 --- a/content/procvars.md +++ b/content/procvars.md @@ -4,7 +4,7 @@ title: First Class Functions # First Class Functions -Nimrod supports closures as well as passing functions. Two different syntaxes available for closures, proc syntax, which is identical to regular procedure syntax, and "do notation", which is a bit shorter. +Nim supports closures as well as passing functions. Two different syntaxes available for closures, proc syntax, which is identical to regular procedure syntax, and "do notation", which is a bit shorter. ``` nimrod import sequtils @@ -15,7 +15,7 @@ echo powersOfTwo.filter do (x: int) -> bool : x > 32 echo powersOfTwo.filter(proc (x: int): bool = x > 32) ``` ``` console -$ nimrod c -r filterclosure.nim +$ nim c -r filterclosure.nim @[64, 128, 256] @[64, 128, 256] ``` diff --git a/content/strings.md b/content/strings.md index 506172e..dfaf6c2 100644 --- a/content/strings.md +++ b/content/strings.md @@ -20,7 +20,7 @@ echo r" "" " echo re"\b[a-z]++\b" ``` ``` console -$ nimrod c -r strings.nim +$ nim c -r strings.nim words words words ⚑ diff --git a/content/types/enums.md b/content/types/enums.md index e79811d..b515d58 100644 --- a/content/types/enums.md +++ b/content/types/enums.md @@ -2,7 +2,7 @@ title: Enums --- # Enums -Enums in Nimrod are like enums in C, but are type-checked. There are no anonymous enums in Nimrod. +Enums in Nim are like enums in C, but are type-checked. There are no anonymous enums in Nim. ``` nimrod type @@ -34,7 +34,7 @@ dec ordinal echo high(char) ``` ```console -$ nimrod c -r enums.nim +$ nim c -r enums.nim cdNorth ord: 0 cdEast ord: 1 cdSouth ord: 2 diff --git a/content/types/objects.md b/content/types/objects.md index b999be5..7f61c1a 100644 --- a/content/types/objects.md +++ b/content/types/objects.md @@ -3,7 +3,7 @@ title: Objects --- # Objects -In Nimrod, objects are like structs from C family languages and define a grouping of fields. They are by default traced by the garbage collector, so there is no need to explicitly free them when allocated. +In Nim, objects are like structs from C family languages and define a grouping of fields. They are by default traced by the garbage collector, so there is no need to explicitly free them when allocated. ``` nimrod type diff --git a/content/varargs.md b/content/varargs.md index 1feee39..475b62c 100644 --- a/content/varargs.md +++ b/content/varargs.md @@ -13,7 +13,7 @@ proc printThings(things: varargs[string]) = printThings "words", "to", "print" ``` ```console -$ nimrod c -r ./varargs1.nim +$ nim c -r ./varargs1.nim words to print @@ -36,7 +36,7 @@ printThings "thing 1", 2, @[4, 5, 6] ``` ```console -$ nimrod c -r ./varargs2.nim +$ nim c -r ./varargs2.nim thing 1 2 @[4, 5, 6] diff --git a/content/variables.md b/content/variables.md index a2b3bfa..75b423b 100644 --- a/content/variables.md +++ b/content/variables.md @@ -3,7 +3,7 @@ title: Variables --- # Variables -Nimrod supports three different types of variables, `let`, `var`, and `const`. As with most things, multiple variables can be declared in the same section. +Nim supports three different types of variables, `let`, `var`, and `const`. As with most things, multiple variables can be declared in the same section. ``` nimrod proc getAlphabet(): string = @@ -43,7 +43,7 @@ e += 1 ``` ``` console -$ nimrod c --verbosity:2 ./variables.nim +$ nim c --verbosity:2 ./variables.nim variables.nim(22, 2) Error: 'let' symbol requires an initialization f: float ^ diff --git a/content/variables/type_casting_inference.md b/content/variables/type_casting_inference.md index 82fef5c..b5ce2f5 100644 --- a/content/variables/type_casting_inference.md +++ b/content/variables/type_casting_inference.md @@ -3,7 +3,7 @@ title: Type Casting and Inference --- # Type Casting and Inference -Nimrod is a statically typed language. As such, each variable has a type associated with it. As seen in the previous example these types are inferred in the `const`, `let` and `var` declarations by the compiler. +Nim is a statically typed language. As such, each variable has a type associated with it. As seen in the previous example these types are inferred in the `const`, `let` and `var` declarations by the compiler. ```nimrod # These types are inferred. @@ -15,7 +15,7 @@ x = y ``` ```console -$ nimrod c -r typeinference.nim +$ nim c -r typeinference.nim typeinference.nim(6, 4) Error: type mismatch: got (string) but expected 'int' ``` @@ -33,6 +33,6 @@ ffi(cast[ptr array[6, char]](addr y[0])) ``` ```console -$ nimrod c -r typecasting.nim +$ nim c -r typecasting.nim ref 002C8030 --> ['F', 'o', 'o', 'b', 'a', 'r'] ``` diff --git a/layouts/default.html b/layouts/default.html index c6e9ac5..07a9d28 100644 --- a/layouts/default.html +++ b/layouts/default.html @@ -2,7 +2,7 @@ - Nimrod by Example - <%= @item[:title] %> + Nim by Example - <%= @item[:title] %> @@ -23,7 +23,7 @@ <%= @items["/toc/"].compiled_content(:snapshot => :last) %>
-

+