Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: ensuring unreachability Date: Tue, 17 Feb 2015 15:51:51 -0500 Organization: A noiseless patient Spider Lines: 33 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 17 Feb 2015 20:51:13 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="3982"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Wcyf32WeAkbFhFr0ye1Mu" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: Cancel-Lock: sha1:RZr5DB5I81HEQMtu1eOiOaeB0S4= Xref: csiph.com comp.lang.java.programmer:31140 On 2/17/2015 5:58 AM, Stefan Ram wrote: > Andreas Leitgeb writes: >> would recognize it as unreachable and barf. So, I'd like to have some >> kind of anti-statement, that's ok to be unreachable, but would make the > > There is no such statement. It occurs to me that there is, sort of: final boolean once; switch (someEnumVar) { case E1: once = true; if (...) { ...; return; } else if (...) { ...; throw ...; } else { ...; continue; // enclosing loop } case E2: once = true; // compiler complains if fall-through possible ... case E3: once = true; // ditto ... } IMHO, this particular cure is a lot worse than the disease. -- esosman@comcast-dot-net.invalid "Don't be afraid of work. Make work afraid of you." -- TLM