Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: Assigning void Date: Sat, 13 Oct 2012 20:25:33 -0400 Organization: A noiseless patient Spider Lines: 83 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 14 Oct 2012 00:19:26 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="6a6a291fa7e9c0bd872c1a9cbe2b371d"; logging-data="7999"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195D8MV4ZJIC+iSyXfOruxvnPcWru8ODYY=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20120925 Icedove/3.0.11 In-Reply-To: Cancel-Lock: sha1:krNFOXJVmGVTvfXW6MvYNt2XAS0= Xref: csiph.com comp.lang.java.programmer:19318 On 10/13/2012 07:55 PM, Jeff Higgins wrote: > On 10/13/2012 03:38 PM, Lew wrote: >> Jeff Higgins wrote: >>> Others have pointed you to the specification. >>> I don't know why it can't be a shorthand if-then-else statement too. > > I suppose that would have been better phrased as: > " ... why it couldn't be ...". > But then I might be accused of trolling > by way of an unanswerable question. > >> >> Whether it could have been, the history of the ternary ?: operator has >> been >> solely as an expression, > > I guess I'll have to trust you here. > I haven't attempted to trace the history. > >> although this is muddied in languages that permit >> standalone expressions. > > I think you begin to muddy the question here. > I haven't asked why not permit standalone expressions. > Only why boolean expression ? block : block ; > could not stand in for an if-then-else statement. > I understand that it *cannot* because of the specification. > >> >> Java chose to prohibit standalone expressions. Having ?: work as a >> statement >> >> x ? 3 : 4; >> >> is no better or worse than would any other expression >> >> 3 + 4; >> >> Java banned the latter, perforce the former. >> >> You asked why. The reason is consistency. Why shouldn't expressions work >> as standalone statements generally, as in C? > > See above. > >> I guess it's to do with the >> philosophy that side effects by themselves are not imperatives. > > I don't understand. If a program statement changes > the state of the program then it is an imperative statement? Ah, Ok. I had to go back an look up side effect. In my new language : boolean expression ? block : block ; is simply an if-then-else statement not an assignment expression so no *side* effect is possible only an effect. > >> >> In any event, to make the ternary ?: a "shorthand if-then-else statement" >> requires we make every expression a statement. > > I don't see it. > >> Is that a good idea? >> >> As it's oppositional to the core ontology of Java, it'll never happen. > > I agree it will likely not happen. > Not sure about the other. > >> >> Now that you know why, > > ?; > >> the debate is open as to whether the reason is >> compelling. >> > Yep. >