Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: Java blunders Date: Mon, 28 Jul 2014 23:17:43 +0000 (UTC) Organization: A noiseless patient Spider Lines: 43 Message-ID: References: <53cef75d$0$291$14726298@news.sunsite.dk> <7s6vs9p395bretqrtdvh9i6til83vfk52p@4ax.com> <53d04b5f$0$291$14726298@news.sunsite.dk> <53d19752$0$295$14726298@news.sunsite.dk> <7lcat9t8j6tuo1v2tm1od8rhvhcgf5i7g9@4ax.com> <7yegqdunyocn$.1g7x8245ot44l$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 28 Jul 2014 23:17:43 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="21858"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199WSG6fADef70U5xVPJkTzgmIxnPvLpPI=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:NfJvqMGzaw6B7d4iv0PxNc/xBbs= Xref: csiph.com comp.lang.java.programmer:29420 On Mon, 28 Jul 2014 23:38:03 +0200, Joerg Meier wrote: > While I often wished we had that kind of operator overloading, my > biggest issue with it is that it looks like it is reassigning ca (and > the explicit syntax, "ca = ca + p;", is even worse), when it in fact > doesn't. And that opens all kind of worm cans: > You're reading too much into it. IIRC Algol 68 had the += operator and you might choose to overload either + or += to represent paying a cheque into an account. It seemed to me that in this case overloading += would read better than overloading + might. > - Can ca still be declared final ? > No - at least you couldn't in Algol 68. It wasn't really an OO language. Although it had a lot of features that became integral parts of the OO paradigm, it didn't any concept of a class or objects that might contain both data and methods. A mode was quite similar to a C struct, and code only existed as procedures and operators. If you take away the "ca =" part, does "ca + p" still do anything? Yes, in exactly the same way that you can throw away the value returned by a Java method or a C function. Could you have "ca+p;", Yes. It would do whatever you'd written the new operator overloading + to do. If it was defined as op +(account,cheque): it would return nothing, while op +(account,cheque)int: might return the new balance and op +=(account,cheque)ref account: would return a reference to the account. As I said: this was Algol 68, which is not an OO language though I suspect that its operator overloading is very much in the spirit of the idea that messages are passed between objects and the A68 compiler had to do more or less the same when parsing an overloaded operator as the Java compiler does when parsing an overloaded method. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |