summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/types.txt67
1 files changed, 67 insertions, 0 deletions
diff --git a/doc/types.txt b/doc/types.txt
new file mode 100644
index 0000000..98ac6de
--- /dev/null
+++ b/doc/types.txt
@@ -0,0 +1,67 @@
+scalar types:
+
+* i8
+* i16
+* i32
+* i64
+* u8
+* u16
+* u32
+* u64
+* uptr
+* iptr
+* usize
+* isize
+* f32
+* f64
+
+enums, struct, union:
+
+* enum Name { A, B, C, D }
+
+ranges:
+
+* T..T
+ + range type
+ + T must be an ordinal
+
+* a..b
+ + range literal
+ + a and b must be ordinals (integer or enum) of the same type
+
+slices and arrays:
+
+* []T - slice
+* [N]T - array of N elements
+* [R]T - array of as many elements as the range constant R covers
+* [E]T - array over the enum E
+* in general, any expression X that can be used in [X]T can also be used in a
+ foreach statement (`for v in X { ... }`)
+
+* sized integers
+ + i8, i16, i32, i64
+ + u8, u16, u32, u64
+ + uptr, iptr: pointer-sized
+ + usize, isize: native machine word size
+* sized floating point
+ + f32, f64
+* bool
+
+* more modern type system than c
+ + distinction between pointers and arrays
+ + slice types (ptr, len)
+ - strings are slices, like rust &str or c++ str_view
+ + dynamic arrays (ptr, len, cap)
+ - manipulation of dynamic arrays is handled by normal functions
+ + type-safe generics
+ + parametric polymorphism (at compile time)
+ + built-in types for vector and matrix math
+ + scalar types have explicit bit sizes
+ - u8, i32, u64, f32, f64
+ + bit set support!
+ + type inference
+ - let x = y
+ - can do like .ENUM_NAME when expecting an enum value, even though
+ otherwise it's `let x = EnumType.ENUM_NAME`
+ + pascal-style postfix dereference, no need for a->b or (*a).b
+ - possibly also auto-dereference when accessing fields