News for hackers. Stuff that matters.
Re:Pretending OOP Never Happened by uryga on Friday May 15, 2020 @08:06PM (#23199008)
also, i just made a possibly interesting connection with JS methods (and their weirdness). in the above implementation, a message is first class, so you can send the same message to multiple objects:

  let moveUp = ['move', [0, 1]];
  p1(...moveUp)
  p2(...moveUp)
but you can't get a `move` that's "bound" to a particular object¹ – the "receiver" is decided when you "send" the message. which reminds me of how JS methods work: `this` is bound to what's "to the left of the dot" when you call a method, so unlike Python,

  obj.foo(1)
is not the same as

  let f = obj.foo
  f(1) // Error: 'this' is undefined
maybe there's a connection to some language that inspired JS' OO model, with prototypes and all that?

---

¹ well, unless you explicitly wrap it in another closure like

  (args) => p1('move', args)
Re:Pretending OOP Never Happened by krallja on Friday May 15, 2020 @08:46PM (#23199321)
p1.move.bind(p1)
Re:Pretending OOP Never Happened by uryga on Friday May 15, 2020 @09:29PM (#23199596)
i know :) the point is that that's not the default (unlike many other languages), and i was wondering about a possible origin for that choice.