3 ms·
Hmm. Check this out: http://en.wikipedia.org/wiki/Type_inference http://en.wikipedia.org/wiki/Type_inference Type checking is a little different, and refers to
by thras 17y ago
Hmm. Check this out: http://en.wikipedia.org/wiki/Type_inference http://en.wikipedia.org/wiki/Type_inference
Type checking is a little different, and refers to some safety measures done at compile time that theoretically guard against certain types of errors. Scripting languages don't do them, and don't miss out on much programming correctness as far as I can tell.
Full run time type inference in C++ is about having a container of something -- let's say void pointers that just point to memory locations, and figuring out what sort of thing they're pointing at. Or similarly, you have a base-class pointer and want to figure out which derived version of the object is being pointed at.
- lincolnq 17y agoI replied to you above, but I'll reply to your specific example here. Your example is really not how PL people talk about type inference. However, you're right that you wouldn't call this example type-checking either... it would probably be a fuzzier term such as "reflection" or "introspection". But certainly not type inference. Do you understand what the wikipedia article you linked is about? Because it's NOT about introspecting the type of a contained object within a container. It's about statically making proofs of the type of a variable based on its usage.
- thras 17y agoSorry, but people use the term this way: http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=qrP&q=%22runtime+type+inference%22&aq=f&oq=&aqi= http://www.google.com/search?hl=en&client=firefox-a&...
- loup-vaillant 17y agoA quick read of this page and its top link strongly suggest that runtime type inference is an optimization designed to speed up the interpretation of dynamically typed programs. It sounds very useful for JIT compilation (to make appropriate code specializations). It's also likely too complex to be implemented in simple interpreters (like Lua's). Note that this term isn't very widely used: we are already in second position at your link. So, unlike ML-style compile-time type inference, runtime type inference is implementation specific. Your earlier statement "Scripting languages have run-time type-inference built in everywhere" is actually ill-typed. However, if you had said "checking" instead of "inference", your sentence would have been correct. Hence my "Err, by "runtime type inference", you actually mean runtime type checking, right?"
- thras 17y agoType checking is what you say when the compiler makes sure that you've used all your types correctly, and spits out an error when you don't. It's there to prevent you from trying to assign an int to a string, for example. "Runtime type checking" is the same thing at runtime. Errors and exceptions get thrown, your program stops. So no, that's not what we're talking about. Here is a description of type checking: http://en.wikipedia.org/wiki/Type_system#Type_checking http://en.wikipedia.org/wiki/Type_system#Type_checking
- jongraehl 17y agoThe I in RTTI stands for "identification", not "inference". Stop saying "runtime type inference".
- thras 17y agoCorrect about RTTI -- and I don't think I used that improperly any place -- but "runtime type inference" is also something people talk about: http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=qrP&q=%22runtime+type+inference%22&aq=f&oq=&aqi= http://www.google.com/search?hl=en&client=firefox-a&...