On Sun, Jan 31, 2010 at 10:09 AM, Alan Tennant
and std::vector is even more type safe, but even less useful.
I think the term "type safe" having the word "safe" in it was created by it's supporters, it's as biased as a term as "strongly typed".
If some code is getting an object then that code already knows why it is requesting that object and what it will do with the object, what methods it would make sense to call on the object, what methods might not be available and the such.
If there were no recursive functions, or objects, no flow control like "for" or "while" available, nothing like a code type either that would allow you to abstract a loop, then your program would be guaranteed "loop safe" and "lockup safe".
Maybe there should be a fixed number of types, like in the original C with no objects, then it would be totally safe.
Variant is superior to Any in a few ways: Speed: Variant does a switch lookup, very fast, inlined visitors. Any requires RTTI which has a *VERY* slow lookup, plus a virtual function call. Memory: Variant does not allocate memory unless your variant is recursive, Any tends to allocate memory in general.