From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,715875e575230543 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-22 00:30:42 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Thought this was funny Date: Wed, 22 Oct 2003 09:31:38 +0200 Message-ID: References: NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1066807841 31114966 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:1376 Date: 2003-10-22T09:31:38+02:00 List-Id: On Wed, 22 Oct 2003 08:44:44 +0200 (MET DST), christoph.grein@eurocopter.com wrote: >> case is >> when true => >> >> >> when false => >> >> >> end case; > >What's so funny about this code. I also normally use if-statements with booleans but >there are circumstances where a case statement seems more appropriate to the >problem at hand. > >Take e.g. kind of double-buffering. I use an array indexed by Boolean and switch >via > "X := not X;" > >In such cases, neither True nor False denote something which is wrong or right, >so I prefer the case statement. > >Switching with a two-valued enumeration is not so elegant, you need a switch >table or a case statement instead of the simple "X := not X;". This is not elegant, but it should work for all enumeration types having two values: X := Enumeration'Val (1 - Enumeration'Pos (X)); --- Regards, Dmitry Kazakov www.dmitry-kazakov.de