From 6a7392eff40642f2a76e331305ecd7ac09900d1c Mon Sep 17 00:00:00 2001
From: flaviut
Date: Fri, 20 Jun 2014 16:34:00 -0400
Subject: [PATCH] Reorganize and add strings
---
content/toc.md | 11 +++---
content/types.md | 24 -----------
content/types/primitive_data_structures.md | 44 +++++++++++++++++++++
content/{numbers.md => types/primitives.md} | 5 ++-
content/types/range.md | 26 ++++++++++++
5 files changed, 79 insertions(+), 31 deletions(-)
create mode 100644 content/types/primitive_data_structures.md
rename content/{numbers.md => types/primitives.md} (93%)
create mode 100644 content/types/range.md
diff --git a/content/toc.md b/content/toc.md
index a909f86..9b5d7e4 100644
--- a/content/toc.md
+++ b/content/toc.md
@@ -5,14 +5,15 @@
* [Variables](/variables/)
* [Result](/variables/result/)
* [Type Casting and Inference](/variables/type_casting_inference/)
-* [Types](/types/)
- * [Objects](/types/objects/)
- * [Enums](/types/enums/)
- * [Distinct Types](/types/distinct/)
* [If, Else, While, Block](/if_else_while/)
* [Case Statements](/case/)
-* [Numbers](/numbers/)
* [For Loops & Iterators](/for_iterators/)
+* [Types](/types/)
+ * [Object Types](/types/objects/)
+ * [Enum Types](/types/enums/)
+ * [Distinct Types](/types/distinct/)
+ * [Primitive Types](/types/primitives/)
+ * [Primitive Data Structures](/types/primitive_data_structures/)
* [Procedures](/procs/)
* [Exceptions](/exceptions/)
* [Varargs](/varargs/)
diff --git a/content/types.md b/content/types.md
index 8ba8416..9bb6e04 100644
--- a/content/types.md
+++ b/content/types.md
@@ -12,27 +12,3 @@ type
let a: int = 2
discard a + MyInteger(4)
```
-
-## Range Types
-
-Range types that guarantee a value will always be within a given range also exist. Whenever possible, out-of-bounds values will fail at compile-time, otherwise they will fail at run-time.
-
-``` nimrod
-type
- TwoDigits* = range[10..99]
-
-let a = 2
-var b: TwoDigits = 99 + a # Fails at run-time
-let c: TwoDigits = 100 # Fails at compile-time
-```
-
-Also note that range types also work on any other ordinal type, so a range over an enum is also valid:
-
-``` nimrod
-type
- MyEnum = enum
- A, B, C, D, E
- BToD = range[B..D]
-
-let value: BToD = C
-```
\ No newline at end of file
diff --git a/content/types/primitive_data_structures.md b/content/types/primitive_data_structures.md
new file mode 100644
index 0000000..00379b4
--- /dev/null
+++ b/content/types/primitive_data_structures.md
@@ -0,0 +1,44 @@
+---
+title: Primitive Data Structures
+---
+# Primitive Data Structures
+
+Nimrod contains several basic builtin data structures: sequences, strings, bitsets, and arrays.
+
+## Strings
+
+``` nimrod
+echo "words words words ⚑"
+echo """
+
+
+ \n\n
+
+
+
+
+
"""
+
+proc re(s: string): string = s
+
+echo r" "" "
+echo re"\b[a-z]++\b"
+```
+``` console
+$ nimrod c -r strings.nim
+words words words ⚑
+
+
+
\n\n
+
+
+
+ "
+\b[a-z]++\b
+```
+
+There are several things to note about strings:
+
+ - Quoted Strings: Created by wrapping the body in triple quotes, they never interpret escape codes
+ - Raw Strings: created by prefixing the string with an `r`. Escape sequences don't work, except for `"`, which can be escaped as `""`
+ - Proc Strings: raw strings, but the method name that prefixes the string is called
\ No newline at end of file
diff --git a/content/numbers.md b/content/types/primitives.md
similarity index 93%
rename from content/numbers.md
rename to content/types/primitives.md
index 553d0ec..9054823 100644
--- a/content/numbers.md
+++ b/content/types/primitives.md
@@ -1,13 +1,14 @@
---
-title: Numbers
+title: Primitives
---
-# Numbers
+# Primitives
Nimrod 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
* floating points numbers: `float32`, `float64`, and `float`, where `float` is the processor's fastest type
+* characters: `char`, and basically an alias for uint8
To indicate the size of an integer literal, append `u` or `i` and the size you'd like to the end. However, this is not typically necessary.
diff --git a/content/types/range.md b/content/types/range.md
new file mode 100644
index 0000000..7220e6b
--- /dev/null
+++ b/content/types/range.md
@@ -0,0 +1,26 @@
+---
+title: Range Types
+---
+# Range Types
+
+Range types that guarantee a value will always be within a given range also exist. Whenever possible, out-of-bounds values will fail at compile-time, otherwise they will fail at run-time.
+
+``` nimrod
+type
+ TwoDigits* = range[10..99]
+
+let a = 2
+var b: TwoDigits = 99 + a # Fails at run-time
+let c: TwoDigits = 100 # Fails at compile-time
+```
+
+Also note that range types also work on any other ordinal type, so a range over an enum is also valid:
+
+``` nimrod
+type
+ MyEnum = enum
+ A, B, C, D, E
+ BToD = range[B..D]
+
+let value: BToD = C
+```
\ No newline at end of file