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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c9d5fc258548b22a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed1.swip.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: How do I write directly to a memory address? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <31c357bd-c8dc-4583-a454-86d9c579e5f4@m13g2000yqb.googlegroups.com> <05a3673e-fb97-449c-94ed-1139eb085c32@x1g2000yqb.googlegroups.com> <4d4c232a$0$28967$882e7ee2@usenet-news.net> <4D4D6506.50909@obry.net> <4d50095f$0$22393$882e7ee2@usenet-news.net> <4d6d56c4$0$11509$882e7ee2@usenet-news.net> <4D6D6A90.2090108@obry.net> <4d6d6e60$0$11509$882e7ee2@usenet-news.net> <4D6E0BA5.9080301@obry.net> Date: Wed, 2 Mar 2011 12:16:03 +0100 Message-ID: NNTP-Posting-Date: 02 Mar 2011 12:16:03 CET NNTP-Posting-Host: dabb3466.newsspool2.arcor-online.net X-Trace: DXC=ePaNSgN]DHa[F<50eo:0knA9EHlD;3Ycb4Fo<]lROoRa8kF On Wed, 02 Mar 2011 01:45:27 -0800, Nasser M. Abbasi wrote: > I wonder what you would think then of the new Java feature (in JDK 7) in > which one can do now do a switch on a string literal? > > http://tech.puredanger.com/java7/#switch > > -------------------------------- > Description: Allow switch statements to use strings in the case blocks. There are problems with this. Case statement in Ada has non-overlapping alternatives checked at compile time. So if more or less complex patterns are used as alternatives, which is the next logical step, it quickly becomes undecidable. Furthermore matching against a string has too many parameters varying from case to case (e.g. case-sensitivity). And it shall have side effects. Usually it is a character stream to match for a pattern. The side effect is that the matched string is consumed. If you are interested in an Ada solution, here is one: http://www.dmitry-kazakov.de/ada/tables.htm This is a library that matches strings against a list of alternatives. It is also integrated into the parser here: http://www.dmitry-kazakov.de/ada/components.htm#12.4 which is table driven. In particular, see 12.4.4. You can instantiate the generic package with an Ada enumeration type and match the source for it. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de