 | Phlip wrote: > JTK wrote: > > > That desn't even make sense Philip. C++ most certainly allows > > "foo.bar()", whether bar() is declared virtual or not. Inheritance or > > lack therof doesn't matter. One of us is missing something here.... > > In C++, given struct A { void bar(); } and struct B { void bar(); }, there > are only two ways to write a foo.bar() where foo could be of type A or B. > They are macros and templates. A template in C++ is essentially a typesafe > macro. Neither permit foo's type to vary at runtime. > > So... > > Dynamic Typing-contrast with Static Typing. Languages like Smalltalk, > Python or Objective C bind method calls entirely at run-time.
objective-c is not fully dynamic, for instance, you can't add or remove fields at runtime.
> > aObject.method(argument); > > That line will evaluate for any aObject that has a .method(argument) to > call. Think of it like the compiler just reads "method" as a text string, > and looks for that string in the given object's member list. > > Static Typing-languages like Java, Eiffel, or C++ bind the type of > objects at compile time, and select the target of messages at > run time based only on types appearing within an object's > inheritance graph. > > Object &aObject = getObject(); > aObject.method(argument); > > That statement requires aObject, at compile time, to refer only to objects > created by classes within the same inheritance graph as Object. At runtime, > calls to .method() dispatch to the correct type of aObject, but unrelated > objects with a .method() could not have compiled.
They *check* the binding at compile time, but at runtime you can change it anyway :)
In glibc you can always use LD_PRELOAD to override functions, methods, or any kind of exported symbols.
|
|