This is an old revision of the document!
Casting
Casting is a very dangerous technique, specially when it comes to the 64 bit mode.
There are functions that return an int value, but this value in reality is a pointer that points to a structure or an object or some other memory construct. This perfectly legal (but also dangerous) in a 32 bit world, but wrong in a 64 bit world where pointers are not more occupying 32 bit, but 64 bit.
So if you are migrating code from VO to X#, please check all your casts. The following code, permitted in VO:
local i := 67 as int local o1 as object local o2 as object o1 := (object) i o2 := object( _cast, i )
will compile in Vulcan.NET, but not in X#.
The first assignment will compile and work in X#, because the compiler knows the type of both variables and inserts a conversion method - so this code is safe.
The second assignment will not compile in X# because it cannot work in a .NET world - it is simply not admitted. A member of the development team stated: For this reason, we intentionally disallowed that specific syntax (OBJECT(_CAST, i)) in order to trap some problems in compile time and not at runtime later.
Please see the entire thread about it in the X# forum: www.xsharp.info/forum/public-product/832-2-0-0-2-cannot-cast-type-int-to-object, specially the last two messages.