From 22853e1463e4f5089844fd90214a99eb063f8fe2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Thu, 1 Oct 2020 20:57:40 +0200 Subject: [PATCH] Start type aliases docs --- docs/Reference/Types/Typedefs.mdr | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/Reference/Types/Typedefs.mdr b/docs/Reference/Types/Typedefs.mdr index a64999b2..332cde61 100644 --- a/docs/Reference/Types/Typedefs.mdr +++ b/docs/Reference/Types/Typedefs.mdr @@ -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 >>>; +@``` -- 2.43.0