Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Not understanding OOP stuff Date: Tue, 25 Jul 2017 00:09:20 +0100 Organization: A noiseless patient Spider Lines: 76 Message-ID: <871sp5ph3z.fsf@bsb.me.uk> References: <1914438.irdbgypaU6@PointedEars.de> <02ec6752-8a2d-4116-9396-71d36dcbd579@googlegroups.com> <87k22zrmtj.fsf@bsb.me.uk> <3298850e-dce6-4384-af58-8bb58830960f@googlegroups.com> <87379msw5i.fsf@bsb.me.uk> <87a83ur1kp.fsf@bsb.me.uk> <3335323.kQq0lBPeGt@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="262d22a30eb43a29f8d3970a6557c777"; logging-data="303"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GJYqejImLuXqIrQACDtTpJfOkmOnC34M=" Cancel-Lock: sha1:ILhSINpI0boKannB6XwY73xutUQ= sha1:JEffe1r2knayj00JX80ARJW1EUA= X-BSB-Auth: 1.b1606be79abc655ec8c1.20170725000920BST.871sp5ph3z.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:33658 Thomas 'PointedEars' Lahn writes: > Ben Bacarisse wrote: > >> ram@zedat.fu-berlin.de (Stefan Ram) writes: >>> Ben Bacarisse writes: >>>>The interesting things are the concepts not the names. ECMAScript >>>>supports many of the concepts that people like Alan Kay would say are >>>>essential to being object-oriented. It supports local retention and >>>>hiding of state along with extreme late binding, but it does not use >>>>message passing as the communication between objects.¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ >>> ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ >>> Why can't I say that when the JavaScript expression >>> >>> o.m() >>> >>> is being evaluated, "the call message »m()« is being >>> sent to the object »o«"¹? >> >> You certainly can. I don't like to say that but it's very far from >> being objectively wrong to do so. > > ACK. > >>> How do you define »message passing«, and which part >>> of your definition is not fulfilled by ECMAScript? >> >> For me, a message should be a thing in itself (in Smalltalk messages >> are, conceptually, objects though almost always optimised away). You >> should be able, when required, to build one at run-time and store it for >> later sending to an object. > > That is possible in ECMAScript implementations: > > var f = function (/* … */) { /* … */ }; > var o = {}; > o.foo = f; > o.foo(); > >> A natural consequence of that would be the ability of an object to forward >> a message to some other object. > > That is also possible in ECMAScript implementations: > > var o2 = {}; > o2.bar = o.foo; > o2.bar(); > > var o3 = {}; > o2.foo.call(o3, 42, 23); > o2.foo.apply(o3, [42, 23]); (Did you mean o.foo or o2.bar here?) That's not really what I mean because because there is no "thing" (I want to avoid saying object here) that is the message. By making the message a think in its own right, message passing systems can disconnect the message from the method that implements it. That's all part of the late binding that some people consider so important. For example, in a message passing language the message can fail if the object does not implement that particular message. In your examples, the message sending (which is just a function call) can't fail for that reason. To my mind, message passing would look rather more like: var msg = ["foo", 42, 23]; o.process_message(msg); This would succeed or fail depending on whether o's prototype chain included a foo method at that time. -- Ben.