doc/manual: put back the manual in the main repository
[nit.git] / doc / manual / virtual_type.md
diff --git a/doc/manual/virtual_type.md b/doc/manual/virtual_type.md
new file mode 100644 (file)
index 0000000..042c721
--- /dev/null
@@ -0,0 +1,20 @@
+# Virtual Types
+
+`type` declares a virtual types in a class. A bound type is
+mandatory. Virtual types can then be used as regular types in the class
+and its subclasses. Subclasses can also redefine it with a more specific
+bound type. One can see a virtual type as an internal formal generic
+parameter or as a redefinable *typedef*.
+
+~~~
+class Foo
+    type E: Object
+    var derp: E
+end
+class Bar
+    super Foo
+    redef type E: Int
+end
+var b = new Bar(5)
+print b.derp + 1 # outputs 6
+~~~