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: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Java blunders Date: Sun, 27 Jul 2014 18:10:42 -0400 Organization: A noiseless patient Spider Lines: 60 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 27 Jul 2014 22:10:43 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="bd4e1cba8d8592bec5d5ed9e4537fbfd"; logging-data="16361"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18SwPhh70/Qbr9x0mFtpeHK" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Cancel-Lock: sha1:qpQOvIcV7UEiUbOC2MTIMc2A9aM= Xref: csiph.com comp.lang.java.programmer:29370 On 7/27/2014 5:18 PM, Martin Gregorie wrote: > On Sun, 27 Jul 2014 14:46:05 -0400, Eric Sosman wrote: > >> On 7/27/2014 2:28 PM, Martin Gregorie wrote: >>> On Sun, 27 Jul 2014 10:13:16 -0700, Roedy Green wrote: >>> >>>> On Sat, 26 Jul 2014 20:11:24 +0000 (UTC), Martin Gregorie >>>> wrote, quoted or indirectly quoted >>>> someone who said : >>>> >>>>> Perl and PHP use . as the string concatenation operator. It seems as >>>>> good as any to me: >>>> >>>> I wonder if . would conflict with its use in qualification. >>>> >>> That's possible. [...] >> >> Yes: An example was offered upthread. Expanding on it: >> >> class Clown { >> static String clownName = "Bozo"; >> static { >> System.out.println(clownName.equals("Bozo")); >> } >> } >> >> What output appears when the class is initialized: "true" or >> "Bozofalse"? > > "False", somewhat obviously, though I don't see what this example has to > do with qualififiers, especially given that some compilers understand > context-sensitive grammar. In any case, I didn't think this was intended > as example code as it looks more like a thinly disguised insult than > anything else. It wasn't intended as an insult, disguised or in plain view. It was intended to illustrate an ambiguity in the proposed syntax. If the `.' were to replace `+' as the string concatenation operator, then the expression `clownName.equals("Bozo")' would be ambiguous: It could mean what we now denote as `clownName.equals("Bozo"), that is, as "Invoke the equals() method of the `clownName' string, passing "Bozo" as the argument." The output would be "true". But if `.' could also be string concatenation, then the expression might equally well mean what we now write as `clownName+equals("Bozo")', that is, "Invoke the equals method of `this' passing "Bozo" as the argument, convert its true or false result to a String, and concatenate that String to `clownName'." The output would be "Bozofalse". All non-void String methods accepting a single suitable argument would suffer the same ambiguity. A JavaPrime (Sumatra?) language could of course adopt rules to resolve the ambiguity -- but would such a suite of rules actually *reduce* the confusion supposedly caused by the use of `+'? C'mon, seriously? Cure worse than disease, I think. -- esosman@comcast-dot-net.invalid