Malcolm V wrote: > Andre Pang wrote: > > > imagination. And, since there's nothing like code to drive the point > > home, here's some C++ for Guido to chew on: > > > > std::vector<int> v; > > v.push_back(69); > > const int number_retrieved_from_vector = v[0]; // Look, no downcast! > > > > That's strongly typed and statically typed. > > Well, from my ten minutes of reading, I would say it isn't strongly > typed as the compiler is casting an int to a const int, but I can be > pedantic.
But thats a up cast rather than a down cast. For instance C++ and C allow a char* to be used as a paramater to a function which takes a const char*. This is a good thing, because what one is allowed to do with a const char* in C++ and C is a strict subset of what one is allowed to do with a char*. However, trying to use a const char* as a parameter to a function that takes a char* will result with at least a warning. So, since Andre code uses an assigns an int to a more restricted type (const int) AFAIAC, he was 100% correct to say that the code snippet he posted was both statically and strongly typed. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo +-----------------------------------------------------------+ "Windows was created to keep stupid people away from UNIX." -- Tom Christiansen _______________________________________________ coders mailing list [email protected] http://lists.slug.org.au/listinfo/coders
