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 23:47:51 +0100 Organization: A noiseless patient Spider Lines: 49 Message-ID: <87379km8vc.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> <871sp5ph3z.fsf@bsb.me.uk> <10884077.O9o76ZdvQC@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="05d2412e23e6c598c86f644d6317b92b"; logging-data="5990"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18GfI4cFpLYRLwA8FonjpF5ba01uWCo6ZM=" Cancel-Lock: sha1:yYvFLx0wnK1Yks/1Vqe4WgOs3To= sha1:7AflzEgVaW1RHsY4P6px1M2HkfE= X-BSB-Auth: 1.e414be9b99f93def09a5.20170725234751BST.87379km8vc.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:33668 Thomas 'PointedEars' Lahn writes: > Ben Bacarisse wrote: > >> […] That's all part of the late binding that some people consider so >> important. >> >> […] 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. > > Calling a method on an object referred to by “o” – which in OOP/UML terms is > equivalent to sending a message to an object where the call’s arguments are > the message contents – *does* fail if that object does not have, and no > object in its prototype chain has, a method of that name *at runtime*. > *That* *is* late binding. Yes, I know. Your example could not fail because it gave the object the target method. I am sure that ECMAScript can something very like Smalltalk's message passing, but the example was not close enough in my opinion. > try > { > o.foo(42, 23); > } > catch (e) > { > /* TypeError: o.foo is not a function */ > } > > ISTM you are confusing messages sent to objects with those appended to a > message queue (which does not need to pertain to objects). Maybe because > you are accustomed to programming languages or software systems where > object-orientation is implemented in that way. No. -- Ben.