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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8623fab5750cd6aa X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news-out.visi.com!petbe.visi.com!news.octanews.net!ash.uu.net!spool.news.uu.net!not-for-mail Date: Thu, 17 Jun 2004 17:47:28 -0400 From: Hyman Rosen User-Agent: Mozilla Thunderbird 0.5 (Windows/20040502) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Improving Ada's image - Was: 7E7 Flight Controls Electronics References: <40b9c99e$0$268$edfadb0f@dread16.news.tele.dk> <1086630278.542788@master.nyc.kbcfp.com> <8xlxc.27603$sS2.845496@news20.bellglobal.com> <1086715817.122983@master.nyc.kbcfp.com> <1086733411.736049@master.nyc.kbcfp.com> <3Auxc.11998$XY6.1296622@read2.cgocable.net> <40C85035.4020706@noplace.com> <40C9EC3B.60304@noplace.com> <40CD90A4.8030005@noplace.com> <40CEDCB5.9000509@noplace.com> <1087325485.307616@master.nyc.kbcfp.com> <1087488758.881520@master.nyc.kbcfp.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1087508848.873039@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1087508848 11763 204.253.250.10 Xref: g2news1.google.com comp.lang.ada:1632 Date: 2004-06-17T17:47:28-04:00 List-Id: Pascal Obry wrote: > Hyman Rosen writes: >>How do you carry this over into Ada? > > As you've done in C, using pointers (I mean access types :): > > type String_Access is access constant String; > type Color_Set is array (Positive range <>) of String_Access; > > Red : aliased constant String := "Red"; > Green : aliased constant String := "Green"; > Blue : aliased constant String := "Blue"; > > Colors : constant Color_Set := (Red'Access, Green'Access, Blue'Access); Good; someone should add this to a tutorial for people converting. I think Dale Stanbrough said that he's maintaining notes on this. I think there's a pleasant symmetry between this code in Ada and enumeration types in C and C++. Here you need to create a variable for each string, and in C you need to create separate strings for printing enumeration literals, while Ada provides this for you. > No need for a "null" terminator. In Ada we have the array bounds: In C also, but just as with strings and buffers, in C these arrays of pointers are sometimes populated dynamically and a null pointer is used to indicate the end.