A lot of programming languages and frameworks do/allow/require something that I can’t seem to find the name for, even though there probably is one in computer science. What they basically do is bind to a variable/object/class/function by name.
Flex example (‘selectAll()’):
<mx:Button click='selectAll()' label='Select All'/>
Mate example (‘price’):
<Injectors target='{QuotePanel}'> <PropertyInjector targetKey='price' source='{QuoteManager}' sourceKey='currentPrice' /> </Injectors>
Java example (‘Foo’):
Class.forName('Foo')
There are many other examples. You get the idea. What troubles me is that there is virtually no way to verify this at compile-time, and not much the IDE can do to help in terms of code completion, navigation, and refactoring. But that’s besides the point.
My question is, what is this called? I don’t think it’s one of these: dynamic binding, name binding, reflection
Update: No, this is not a quiz, sorry if it sounds like one. It’s simply a matter of ‘name that song’ for programming.
Update: Answers that helped:
- From Tim Lesher: It’s called ‘late binding’, ‘dynamic binding’, or ‘runtime binding’. The fact that it binds by a string is just an implementation detail…
- From Konrad Rudolph: …it’s simply input for an interpreter.
Update: As people have correctly pointed out, some of the examples are late binding, some are reflection, some are runtime-evaluation (interpretation), etc. However, I conclude there probably is no name that describes them all. It’s just a bunch of examples that do have something in common, but not enough to give it a name. I liked the ‘everything is a string’ answer, but even though it’s funny, it doesn’t fully do it justice either.
It’s called ‘late binding’, ‘dynamic binding’, or ‘runtime binding’. The fact that it binds by a string is just an implementation detail, although it does imply that the string-to-symbol mapping exists at runtime (which some languages, like c++, don’t provide).
‘Introspection’ or ‘reflection’, on the other hand, refer to the ability to find out what interfaces, methods, or attributes an object implements at runtime.
It’s true that dynamically-bound symbols can’t be verified before execution; that’s what makes them different from statically-bound symbols.