News for hackers. Stuff that matters.
Re:Kay on the Meaning of "Object-Oriented Programming" by igrekel on Tuesday June 07, 2011 @11:23AM (#2629474)
Not 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).
Re:Kay on the Meaning of "Object-Oriented Programming" by IgorPartola on Tuesday June 07, 2011 @12:26PM (#2629760)

  Foo.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++;
  }
Re:Kay on the Meaning of "Object-Oriented Programming" by igrekel on Tuesday June 07, 2011 @01:32PM (#2630060)
Not 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"

Re:Kay on the Meaning of "Object-Oriented Programming" by gliese1337 on Tuesday June 07, 2011 @02:10PM (#2630246)
There 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.

Re:Kay on the Meaning of "Object-Oriented Programming" by justincormack on Tuesday June 07, 2011 @04:38PM (#2630756)
Lua 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.
Re:Kay on the Meaning of "Object-Oriented Programming" by fluidcruft on Tuesday June 07, 2011 @12:45PM (#2629860)
Based on his references to biology and cell signaling as inspirations, I think you're on the money.