5 ms·
What does Kay mean by late-binding? ... not the dynamic binding of overriding methods in a subclass or virtual functions (C++)? The last paragraphs compared sma
by cconroy 15y ago
What does Kay mean by late-binding? ... not the dynamic binding of overriding methods in a subclass or virtual functions (C++)? The last paragraphs compared smalltalk with lisp in this respect.
- nvarsj 15y agoI think he does mean runtime binding, as with a virtual function call. But probably more extreme - instead of a lookup table to find the static type, a message is simply sent to the receiving object. The object itself then handles it based on its type definition (which itself could be defined at runtime).
- gnaritas 15y agoAnd the object can handle messages for which no function exists at all.
- sedachv 15y agoThis (#doesNotUnderstand:) is not very widely known but extremely important: http://carcaddar.blogspot.com/2009/04/closure-oriented-metaprogramming-via.html?showComment=1239507240000#c7399536579144180363 http://carcaddar.blogspot.com/2009/04/closure-oriented-metap... http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg02096.html http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/m...
- igrekel 15y agoNot being in his head, I'll try to guess from what I know of smalltalk. It means the actual binding of a message to the method to execute is done only when the message is received. TOo give you an idea, you may associate some code to specific messages to an object at runtime, you may also implement doesNotUnderstand and decide how to handle messages who don't have corresponding methods (forward it to another object, have some special behavior, create the method on the fly as needed).
- IgorPartola 15y agoFoo.counter = 0; Foo.prototype.handle = function(message, data) { if (message == 'bar' && Foo.counter < 3) { return this.bar(data) } else { throw "I forgot about 'bar'." } Foo.counter++; }
- igrekel 15y agoNot too sure about what the point is, or maybe it is just my limited knowledge of javascirpt that's playing me tricks. In any case I didn't know of a prototype.handle function and can't figure out any way for it to intervene in the usual way of calling functions on an object. var f=new Foo() f.bar() //Just says that f.bar is undefined and therefor not a function //If I add f.bar=function(something){return "nothing"} //Calling f.bar("ABC") //Many times always answers "nothing"
- gliese1337 15y agoThere isn't such a function built-in, though something like it (a doNotUnderstand functionality to call a default function instead of throwing an error if the requested field isn't found on an object) has been proposed as a future addition to the JavaScript standard. IgorPartola's example code won't intervene in the usual function-call process; rather, it provides a tacked-on means of simulating message sending behavior that ought to be included in the language's syntax under Kay's definition of OO. With this convention, you'd never call bar(), or any other method, directly; you'd call handle to send a 'bar' message to the object instead. Then, if you send a message the object doesn't understand, handle() can route it properly.
- justincormack 15y agoLua has this, with metatables that can set methods to handle undefined stuff. It is actually very useful and you can do a lot with it.
- fluidcruft 15y agoBased on his references to biology and cell signaling as inspirations, I think you're on the money.
- arethuza 15y agoPossibly the full dynamic dispatch (AKA multi-methods) that you get with systems like CLOS - where the types of all of the arguments are used to compute matching methods, not just the type of the object you are invoking the method on. http://c2.com/cgi/wiki?SmalltalkLateBinding http://c2.com/cgi/wiki?SmalltalkLateBinding
- bitwize 15y agoIt means when you have a name for something, the association between the name and the thing should be done as late as possible. In the case of a method call, the method to be invoked for a given message name should take place at the time of the call. I've a lot of respect for Dr. Kay, but history has shown him to be wrong on this point: strong static typing and binding things as early as possible is how robust systems are built and how errors are minimized. However I won't doubt that the Smalltalk approach is probably right for its original intended purpose (exploratory or didactic programming).
- swannodette 15y ago> strong static typing and binding things as early as possible is how robust systems are built and how errors are minimized. Huh? What about Erlang?
- prodigal_erik 15y agoErlang is very good at making systems that can sort of muddle along and keep running despite containing serious mistakes, but it's almost no help with preventing or fixing them. Every static type (even inferred) does the work of a number of unit tests, though of course not all.
- swannodette 15y agoI suppose you've never head of Dialyzer which gives much better coverage than most static type systems.
- prodigal_erik 15y agoNo I had not. If Erlang now has working type checking, that's a huge advance. But I have to wonder why the Wikipedia page still claims Erlang is dynamically typed and doesn't mention this, and the getting-started guide barely names Dialyzer and doesn't demonstrate it at all (instead it's somewhere in the middle of the FAQ). How much consensus is there that it's ready for prime time?
- stonemetal 15y agoC++ virtual functions are close but it would have to have a method missing construct before it would meet his full definition.
- russell 15y agoBinding time was thought of as compile time, link time, runtime, and even execution time. So in the time frame he was talking about nearly everyting had early binding, compile time or link time when libraries were included. With todays languages, like Java you have runtime loading which would be considered late time binding. Dynamic languages like Python have extremely late binding where the operator/operand type binding is done at the operator execution time.