Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Spurious diagnostic messages Date: Wed, 27 May 2015 10:40:38 -0700 Organization: None to speak of Lines: 38 Message-ID: <87d21lnckp.fsf@kst-u.example.com> References: <7af4f97c-d5f3-4bbd-ab6b-6c5b677fa880@googlegroups.com> <556052c8.7856531@news.xs4all.nl> <871ti6rawv.fsf@kst-u.example.com> <3qh2ma1vojvb0add103h8tabbcb5gedhhb@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="9be37d943435275679235b07c7947eef"; logging-data="5922"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DGqIglBaklRV6dTBTw8cI" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:bjBUpofTIcSS9RzDuluudXoYaQU= sha1:473ihOz/mcJL5iEV+IdCi0Dv96A= Xref: csiph.com comp.lang.c:62685 Morris Dovey writes: [...] > One that I've wondered about from time to time is > > switch (x) > { case { expression }: > /* case code */ > /* other cases */ > } > > where is code that examines x and yields TRUE (execute > case code) or FALSE (do not execute case code) – of which an > interesting subset/derivative possibility might be: > > switch (x) > { case { function(x) }: > /* case code */ > /* other cases */ > } > > which causes the named function to be invoked to produce the > TRUE/FALSE result. What's the point of specifying x in `switch (x)`? Can the expression refer to things other than x? If it can't, it seems like an odd restriction. If it can, it's just an if/else in disguise. > C actually does have a (primitive) range-testing feature: > > if (x >= lower_bound && x <= upper_bound) /* x in range! */; > > :-) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"