Index: uspace/dist/src/sysel/demos/arith.sy
===================================================================
--- uspace/dist/src/sysel/demos/arith.sy	(revision 074444f189ee9356421b26e70454fae61c81def3)
+++ uspace/dist/src/sysel/demos/arith.sy	(revision 38aaacc20a85af2361a0240ac2e7d643e086ecfa)
@@ -30,46 +30,49 @@
 	fun Main() is
 		-- Test addition, multiplication and precedence.
-		Builtin.WriteLine("2*2 + 2*2 =");
-		Builtin.WriteLine(2*2 + 2*2);
-		Builtin.WriteLine("(expected: 8)");
+		Builtin.Write("2*2 + 2*2 = ");
+		Builtin.Write(2*2 + 2*2);
+		Builtin.WriteLine(" (expected: 8)");
 
 		-- Test subtraction, multiplication and precedence.
-		Builtin.WriteLine("1111 - 1 - 10 - 10*10 - 10*10*10 =");
-		Builtin.WriteLine(1111 - 1 - 10 - 10*10 - 10*10*10);
-		Builtin.WriteLine("(expected: 0)");
+		Builtin.Write("1111 - 1 - 10 - 10*10 - 10*10*10 = ");
+		Builtin.Write(1111 - 1 - 10 - 10*10 - 10*10*10);
+		Builtin.WriteLine(" (expected: 0)");
 
 		-- Test parenthesized sub-expressions.
-		Builtin.WriteLine("10 * (1 - 1) =");
-		Builtin.WriteLine(10 * (1 - 1));
-		Builtin.WriteLine("(expected: 0)");
+		Builtin.Write("10 * (1 - 1) = ");
+		Builtin.Write(10 * (1 - 1));
+		Builtin.WriteLine(" (expected: 0)");
 
 		-- Test unary plus and minus.
-		Builtin.WriteLine("(+1) - (-1) - (+(+1)) + (+(-1)) = ");
-		Builtin.WriteLine((+1) - (-1) - (+(+1)) + (+(-1)));
-		Builtin.WriteLine("(expected: 0)");
+		Builtin.Write("(+1) - (-1) - (+(+1)) + (+(-1)) = ");
+		Builtin.Write((+1) - (-1) - (+(+1)) + (+(-1)));
+		Builtin.WriteLine(" (expected: 0)");
 
 		-- Test signed multiplication.
-		Builtin.WriteLine("+1 * +1 = ");
-		Builtin.WriteLine(+1 * +1);
-		Builtin.WriteLine("(expected: 1)");
-		Builtin.WriteLine("-1 * -1 = ");
-		Builtin.WriteLine(-1 * -1);
-		Builtin.WriteLine("(expected: 1)");
-		Builtin.WriteLine("+1 * -1 = ");
-		Builtin.WriteLine(+1 * -1);
-		Builtin.WriteLine("(expected: -1)");
-		Builtin.WriteLine("-1 * +1 = ");
-		Builtin.WriteLine(-1 * +1);
-		Builtin.WriteLine("(expected: -1)");
+		Builtin.Write("+1 * +1 = ");
+		Builtin.Write(+1 * +1);
+		Builtin.WriteLine(" (expected: 1)");
+
+		Builtin.Write("-1 * -1 = ");
+		Builtin.Write(-1 * -1);
+		Builtin.WriteLine(" (expected: 1)");
+
+		Builtin.Write("+1 * -1 = ");
+		Builtin.Write(+1 * -1);
+		Builtin.WriteLine(" (expected: -1)");
+
+		Builtin.Write("-1 * +1 = ");
+		Builtin.Write(-1 * +1);
+		Builtin.WriteLine(" (expected: -1)");
 
 		-- Test multiplication with large result.
-		Builtin.WriteLine("1000000 * 1000000 * 1000000 * 1000000 =");
-		Builtin.WriteLine(1000000 * 1000000 * 1000000 * 1000000);
-		Builtin.WriteLine("(expected: 1000000000000000000000000)");
+		Builtin.Write("1000000 * 1000000 * 1000000 * 1000000 = ");
+		Builtin.Write(1000000 * 1000000 * 1000000 * 1000000);
+		Builtin.WriteLine(" (expected: 1000000000000000000000000)");
 
 		-- Test large literals.
-		Builtin.WriteLine("1000000000000000000000000 =");
-		Builtin.WriteLine(1000000000000000000000000);
-		Builtin.WriteLine("(expected: 1000000000000000000000000)");
+		Builtin.Write("1000000000000000000000000 = ");
+		Builtin.Write(1000000000000000000000000);
+		Builtin.WriteLine(" (expected: 1000000000000000000000000)");
 
 		-- Test large factorials.
Index: uspace/dist/src/sysel/demos/autobox.sy
===================================================================
--- uspace/dist/src/sysel/demos/autobox.sy	(revision 38aaacc20a85af2361a0240ac2e7d643e086ecfa)
+++ uspace/dist/src/sysel/demos/autobox.sy	(revision 38aaacc20a85af2361a0240ac2e7d643e086ecfa)
@@ -0,0 +1,55 @@
+--
+-- Copyright (c) 2010 Jiri Svoboda
+-- All rights reserved.
+--
+-- Redistribution and use in source and binary forms, with or without
+-- modification, are permitted provided that the following conditions
+-- are met:
+--
+-- o Redistributions of source code must retain the above copyright
+--   notice, this list of conditions and the following disclaimer.
+-- o Redistributions in binary form must reproduce the above copyright
+--   notice, this list of conditions and the following disclaimer in the
+--   documentation and/or other materials provided with the distribution.
+-- o The name of the author may not be used to endorse or promote products
+--   derived from this software without specific prior written permission.
+--
+-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+-- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+-- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+-- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+-- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+--
+
+class AutoboxingDemo is
+	fun Main() is
+		var b : Bool;
+		var c : Char;
+		var i : Int;
+		var s : String;
+
+		--
+		-- Automatic conversion of each primitive type to the
+		-- respective boxed type.
+		--
+		b = true;
+		Builtin.WriteLine(b.Value);
+		c = 'a';
+		Builtin.WriteLine(c.Value);
+		i = 1;
+		Builtin.WriteLine(i.Value);
+		s = "Hello";
+		Builtin.WriteLine(s.Value);
+
+		-- Anything can be converted to Object.
+		foo(b, c, i, s);
+	end
+
+	fun foo(args : Object[], packed) is
+	end
+end
Index: uspace/dist/src/sysel/demos/deleg.sy
===================================================================
--- uspace/dist/src/sysel/demos/deleg.sy	(revision 38aaacc20a85af2361a0240ac2e7d643e086ecfa)
+++ uspace/dist/src/sysel/demos/deleg.sy	(revision 38aaacc20a85af2361a0240ac2e7d643e086ecfa)
@@ -0,0 +1,73 @@
+--
+-- Copyright (c) 2010 Jiri Svoboda
+-- All rights reserved.
+--
+-- Redistribution and use in source and binary forms, with or without
+-- modification, are permitted provided that the following conditions
+-- are met:
+--
+-- o Redistributions of source code must retain the above copyright
+--   notice, this list of conditions and the following disclaimer.
+-- o Redistributions in binary form must reproduce the above copyright
+--   notice, this list of conditions and the following disclaimer in the
+--   documentation and/or other materials provided with the distribution.
+-- o The name of the author may not be used to endorse or promote products
+--   derived from this software without specific prior written permission.
+--
+-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+-- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+-- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+-- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+-- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+--
+
+class DelegateDemo is
+	fun Main() is
+		var demo : DelegateClass;
+
+		demo = new DelegateClass();
+		demo.Run();
+	end
+end
+
+class DelegateClass is
+	fun Run() is
+		var op : BinaryOp;
+
+		-- The anonymous delegate to self.Add is implicitly
+		-- converted to BinaryOp. This is allowed as long as
+		-- the signature matches.
+		op = Add;
+
+		-- Pass delegate to Operate()
+		Operate(op, "Add");
+
+		-- Obviously the intermediate step through a variable
+		-- is redundant.
+		Operate(Subtract, "Subtract");
+	end
+
+	-- Function having delegate as the first parameger
+	fun Operate(op : BinaryOp; opName : string) is
+		Builtin.Write(opName + "(1, 2): ");
+		Builtin.WriteLine(op(1, 2));
+	end
+
+	-- A function matching the delegate signature
+	fun Add(a : int; b : int) : int is
+		return a + b;
+	end
+
+	-- Another function matching the delegate signature
+	fun Subtract(a : int; b : int) : int is
+		return a - b;
+	end
+
+	-- Declaration of a delegate.
+	deleg BinaryOp(a : int; b : int) : int;
+end
Index: uspace/dist/src/sysel/demos/gen.sy
===================================================================
--- uspace/dist/src/sysel/demos/gen.sy	(revision 38aaacc20a85af2361a0240ac2e7d643e086ecfa)
+++ uspace/dist/src/sysel/demos/gen.sy	(revision 38aaacc20a85af2361a0240ac2e7d643e086ecfa)
@@ -0,0 +1,106 @@
+--
+-- Copyright (c) 2010 Jiri Svoboda
+-- All rights reserved.
+--
+-- Redistribution and use in source and binary forms, with or without
+-- modification, are permitted provided that the following conditions
+-- are met:
+--
+-- o Redistributions of source code must retain the above copyright
+--   notice, this list of conditions and the following disclaimer.
+-- o Redistributions in binary form must reproduce the above copyright
+--   notice, this list of conditions and the following disclaimer in the
+--   documentation and/or other materials provided with the distribution.
+-- o The name of the author may not be used to endorse or promote products
+--   derived from this software without specific prior written permission.
+--
+-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+-- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+-- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+-- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+-- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+--
+
+-- Demonstrate generic classes.
+
+class GenericsDemo is
+	fun Main() is
+		Builtin.WriteLine("Let's try some generics.");
+
+		var f : B/int/string;
+		var g : A/string/int;
+		var s : string;
+
+		f = new B/int/string();
+		g = new A/string/int();
+
+		-- This should be okay.
+		f = f;
+		g = f;
+
+		-- Method
+		g.set_a("Lorem");
+		f.set_a("ipsum");
+		s = g.get_a();
+		s = f.get_a();
+
+		-- Named property
+		g.P = "Lorem";
+		f.P = "ipsum";
+		s = g.P;
+		s = f.P;
+
+		-- Indexed property
+		g[1] = "Lorem";
+		f[1] = "ipsum";
+		s = g[1];
+		s = f[1];
+	end
+end
+
+-- Generic class with two type parameters
+class A/u/v is
+	-- Variable whose type is one of the parameters
+	var a : u;
+
+	-- Member function whose argument type is one of the parameters
+	fun set_a(arg : u) is
+		a = arg;
+	end
+
+	fun get_a() : u is
+		return a;
+	end
+
+	-- Property whose type is one of the type parameters
+	prop P : u is
+		get is
+			return a;
+		end
+		set value is
+			a = value;
+		end
+	end
+
+	-- Indexed property whose type is one of the type arguments
+	prop self[i : int] : u is
+		get is
+			return a;
+		end
+		set value is
+			a = value;
+		end
+	end
+end
+
+-- Generic class derived from another generic class
+--
+-- Note the swapping of type arguments.
+--
+class B/v/u : A/u/v is
+end
Index: uspace/dist/src/sysel/demos/list.sy
===================================================================
--- uspace/dist/src/sysel/demos/list.sy	(revision 074444f189ee9356421b26e70454fae61c81def3)
+++ uspace/dist/src/sysel/demos/list.sy	(revision 38aaacc20a85af2361a0240ac2e7d643e086ecfa)
@@ -30,21 +30,19 @@
 class ListDemo is
 	fun Main() is
-		var list : List;
-		var i : Int;
+		var list : List/int;
 
-		list = new List();
+		list = new List/int();
 		list.Init();
 
-		-- We need autoboxing or generics to get rid of this mess.
-		i = new Int(); i.Value = 5; list.Append(i);
-		i = new Int(); i.Value = 6; list.Append(i);
-		i = new Int(); i.Value = 7; list.Append(i);
-		i = new Int(); i.Value = 8; list.Append(i);
+		list.Append(5);
+		list.Append(6);
+		list.Append(7);
+		list.Append(8);
 
-		var n : ListNode;
+		var n : ListNode/int;
 
 		n = list.First;
 		while n != nil do
-			Builtin.WriteLine((n.value as Int).Value);
+			Builtin.WriteLine(n.Value);
 			n = n.Next;
 		end
Index: uspace/dist/src/sysel/demos/property.sy
===================================================================
--- uspace/dist/src/sysel/demos/property.sy	(revision 074444f189ee9356421b26e70454fae61c81def3)
+++ uspace/dist/src/sysel/demos/property.sy	(revision 38aaacc20a85af2361a0240ac2e7d643e086ecfa)
@@ -33,5 +33,5 @@
 	prop X : int is
 		get is
-			Builtin.WriteLine("Getting value of X which is");
+			Builtin.Write("Getting value of X which is ");
 			Builtin.WriteLine(x);
 			return x;
@@ -39,5 +39,5 @@
 
 		set value is
-			Builtin.WriteLine("Setting value of X to");
+			Builtin.Write("Setting value of X to ");
 			Builtin.WriteLine(value);
 			x = value;
@@ -51,7 +51,7 @@
 	prop self[index : int] : int is
 		get is
-			Builtin.WriteLine("Getting property with index ");
-			Builtin.WriteLine(index);
-			Builtin.WriteLine("which is");
+			Builtin.Write("Getting property with index ");
+			Builtin.Write(index);
+			Builtin.Write(" which is ");
 			Builtin.WriteLine(iprops[index]);
 
@@ -60,7 +60,7 @@
 
 		set value is
-			Builtin.WriteLine("Setting property with index ");
-			Builtin.WriteLine(index);
-			Builtin.WriteLine("to");
+			Builtin.Write("Setting property with index ");
+			Builtin.Write(index);
+			Builtin.Write(" to ");
 			Builtin.WriteLine(value);
 
@@ -110,5 +110,5 @@
 		i = a.X;
 
-		Builtin.WriteLine("Main(): Got ");
+		Builtin.Write("Main(): Got ");
 		Builtin.WriteLine(i);
 
@@ -121,5 +121,5 @@
 		i = a[1];
 
-		Builtin.WriteLine("Main(): Got ");
+		Builtin.Write("Main(): Got ");
 		Builtin.WriteLine(i);
 
Index: uspace/dist/src/sysel/lib/boxed.sy
===================================================================
--- uspace/dist/src/sysel/lib/boxed.sy	(revision 074444f189ee9356421b26e70454fae61c81def3)
+++ uspace/dist/src/sysel/lib/boxed.sy	(revision 38aaacc20a85af2361a0240ac2e7d643e086ecfa)
@@ -28,5 +28,6 @@
 
 --
--- Declarations for boxed variants of primitive types.
+-- Declarations for boxed variants of primitive types. The interpreter
+-- binds to these types internally. They must be declared.
 --
 
Index: uspace/dist/src/sysel/lib/list.sy
===================================================================
--- uspace/dist/src/sysel/lib/list.sy	(revision 074444f189ee9356421b26e70454fae61c81def3)
+++ uspace/dist/src/sysel/lib/list.sy	(revision 38aaacc20a85af2361a0240ac2e7d643e086ecfa)
@@ -27,11 +27,11 @@
 --
 
--- Doubly-linked non-generic list.
-class List is
-	var head : ListNode;
+-- Doubly-linked list.
+class List/t is
+	var head : ListNode/t;
 
 	-- Initialize list.
 	fun Init() is
-		head = new ListNode();
+		head = new ListNode/t();
 		head.prev = head;
 		head.next = head;
@@ -39,11 +39,11 @@
 
 	-- Append new entry at the end of the list.
-	fun Append(data : Object) is
-		var n : ListNode;
-		var ntl : ListNode;
+	fun Append(data : t) is
+		var n : ListNode/t;
+		var ntl : ListNode/t;
 
 		ntl = head.prev;
 
-		n = new ListNode();
+		n = new ListNode/t();
 		n.value = data;
 
@@ -57,5 +57,5 @@
 
 	-- Return first node in the list or @c nil if there is none.
-	prop First : ListNode is
+	prop First : ListNode/t is
 		get is
 		    return get_first();
@@ -64,5 +64,5 @@
 
 	-- Return first node in the list or @c nil if there is none.
-	fun get_first() : ListNode is
+	fun get_first() : ListNode/t is
 		if head.next == head then
 			return nil;
@@ -73,13 +73,13 @@
 end
 
-class ListNode is
-	var value : Object;
+class ListNode/t is
+	var value : t;
 
-	var prev : ListNode;
-	var next : ListNode;
-	var head : ListNode;
+	var prev : ListNode/t;
+	var next : ListNode/t;
+	var head : ListNode/t;
 
 	-- Value stored in this node.
-	prop Value : Object is
+	prop Value : t is
 		get is
 			return value;
@@ -88,5 +88,5 @@
 
 	-- Previous node in list.
-	prop Prev : ListNode is
+	prop Prev : ListNode/t is
 		get is
 			return get_prev();
@@ -95,5 +95,5 @@
 
 	-- Next node in list.
-	prop Next : ListNode is
+	prop Next : ListNode/t is
 		get is
 			return get_next();
@@ -102,5 +102,5 @@
 
 	-- Get next node.
-	fun get_next() : ListNode is
+	fun get_next() : ListNode/t is
 		if next != head then
 			return next;
@@ -111,5 +111,5 @@
 
 	-- Get previous node.
-	fun get_prev() : ListNode is
+	fun get_prev() : ListNode/t is
 		if prev != head then
 			return next;
