Well the first example is simply incomplete. As you can see the PObject type is defined as a reference to the TObj object type, which isn't defined anywhere. The error tells you that TObj is an undeclared identifier when you tried to do that. When you created var TObj = "aa" you created a TObj identifier, but it points to string, and not to a type which is what type PObject = ref TObj not nil expects, the error message tells you that it expected a type. To get the example working you simply need to define TObj as an object type of some kind, the reason this isn't done in the example is probably just because it would add needless noise to have an object with fields that didn't have anything to do with the example.