Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!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: Sat, 26 Jul 2014 21:04:10 +0000 (UTC) Organization: A noiseless patient Spider Lines: 55 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 26 Jul 2014 21:04:10 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="28344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+g2kwy/5mr5FKUupPwDPb6HJ5LrhLgvQ=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:18BXN9WWccZv+Xr56OP1BDloeLs= Xref: csiph.com comp.lang.java.programmer:29353 On Sat, 26 Jul 2014 08:31:10 -0700, Roedy Green wrote: > On Thu, 24 Jul 2014 19:31:29 -0400, Arne Vajhøj wrote, > quoted or indirectly quoted someone who said : > >>A new concatenation operator would not solve that problem in all cases. > > Assume there were two distinct + operators. > That's just operator overloading. Algol 68 explicitly allowed that. The following was how the standard operator for adding integers was defined in the Algol 68R standard prelude: op + = (int a,b) int: ( a + b ); But its easy to overload. If we assume that the string mode was declared as: mode string = [1: 0 flex]]char; then we can overload + to concatenate two strings: op + = (string a,b) string: begin string c; for i from lwb a to upb a do c[i] := a[i] od; int n := upb c; for i from lwb b to upb b do c[i+n] := b[i] od; c; end The syntax may not be quite right (its been 37 years and I don't have a compiler to check it with), but in Algol 68R you could (and I did) overload any operator by declaring extensions in just that way. > If you used the new operators to express your intent, an expression that > is legal now, but gives the wrong result would become an illegal > expression. > It can be very elegant. There was am Algol 68R extension for defining and plotting 2D diagrams It used two base modes: a sketch (which was a plottable object but yet scaled or coloured, etc. and a picture, which was scaled and ready for output. There were also a number of predefined sketch extensions, e.g. circle, rectangle, text and a few more overloads for + so you could write something like this: picture p = circle(3.0) + rectangle(3.5, 4.5) + text("Title"); print(p); Easy to read and write or what? -- martin@ | Martin Gregorie gregorie. | Essex, UK org |