3 ms·
Is Dynamic Dispatching supposed to be the holy grail of OOP per Smalltalk’s ideal design of message passing? An example of Dynamic Dispatch, is say you create
by blackrock 6y ago
Is Dynamic Dispatching supposed to be the holy grail of OOP per Smalltalk’s ideal design of message passing?
An example of Dynamic Dispatch, is say you create a Class object of a person. And you give that object the method ‘jump’.
Then, you create say 30 persons, one for each student in your classroom. Then, you collect them all into a list. And you iterate through that list, and tell each person to jump.
So in Python, it might be something like:
John = Person()
Jane = Person()
# then create 30 of them students
student_list = []
student_list.extend([John, Jane, ...])
# Then make them all jump.
for kid in student_list:
kid.jump()
So, per my understanding this is what Dynamic Dispatch is. It allows you to reassign a variable to an existing set of objects, and to massively activate all of them. Such that, you’re sending an execute command to all of the associated objects.
Was this the genius innovation to OOP, as opposed to procedural languages before it? And can something like this be simulated in other imperative or functional type of programming languages?
- andrekandre 6y ago> And can something like this be simulated in other imperative or functional type of programming languages? im pretty sure it can be, but without it being built in, it probably would be a chore > Was this the genius innovation to OOP, as opposed to procedural languages before it? i think so (if you consider smallltalk to be oop, as opposed to c++ or simula)... afaik, the other goal that would be enabled by message-passing, was to enable something akin to the actor system... but smalltalk largely stalled after st80....