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: a07f3367d7,b85c1b84f840dc22 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!news.netcologne.de!newsfeed-fusi2.netcologne.de!newsfeed.straub-nv.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: I need a little help - it's been a long time - with enumeration type and for use representation 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: <7495d29e-0361-4eba-9e22-a770ae50f113@d5g2000yqm.googlegroups.com> <1hgihvw2ld2nr.cg5ve3xaww03.dlg@40tude.net> Date: Sat, 14 Nov 2009 10:24:43 +0100 Message-ID: NNTP-Posting-Date: 14 Nov 2009 10:24:47 CET NNTP-Posting-Host: 5b4b319c.newsspool2.arcor-online.net X-Trace: DXC=GKOk@DJFdHo>jlK2>IgHGdA9EHlD;3Ycb4Fo<]lROoRa8kF On Fri, 13 Nov 2009 14:30:44 -0700, Jeffrey R. Carter wrote: > Dmitry A. Kazakov wrote: >> >> I do it differently. I have the pattern: >> >> procedure Get (Text : String; Pointer : in out Integer; Value : out Type) >> >> which I consistently deploy everywhere. Get takes a textual representation >> of Type from Text at Pointer and advances Pointer to the first position >> following it. The result is returned though Value. >> >> However, yes, usually I use a plain type conversion: >> >> Get (Text, Pointer, Integer (Value)); >> >> rather than Type'Val (when I am too lazy to instantiate the generic >> packages once again with Type) > > I still don't see where you would use 'Val. As I said in place of type conversion. If you have some bit pattern as a number you can use either Val or type conversion: declare N : Integer; begin Get (Text, Pointer, N); Value := Type'Val (N); --- or Value := Type (N) ... Type'Val is probably semantically cleaner than conversion. Then there are cases where conversion cannot be used, e.g. for formal discrete types in generics. There you have to use 'Val instead of conversion, 'Suc instead of +1 etc. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de