]> Nishi Git Mirror - gwion.git/commitdiff
Start type aliases docs
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Thu, 1 Oct 2020 18:57:40 +0000 (20:57 +0200)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Thu, 1 Oct 2020 18:57:40 +0000 (20:57 +0200)
docs/Reference/Types/Typedefs.mdr

index a64999b2de1d98689eb5911a596355ae4b8a5b05..332cde614f958e9df4c0494bdd2b3fcf4bda86fd 100644 (file)
@@ -1 +1,28 @@
-# Typedefs
+# Type aliases
+
+Create an alias for a previously defined type.
+
+@``` typedef_simple.gw
+typedef int MyInt;
+var MyInt i;
+<<< i >>>;
+<<< i $ int >>>;
+@```
+
+Aliases can also point to an array type
+
+@``` typedef_array.gw
+typedef float[3] Point;
+var Point p;
+foreach(a : p)
+  <<< a >>>;
+@```
+
+
+Aliases can be used to refer to a type family
+
+@``` typedef_tmpl.gw
+typedef Ptr:[int] IntPtr;
+var IntPtr int_ptr;
+<<< int_ptr >>>;
+@```