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,7be3870dd9c9518f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-14 18:20:02 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!lnsnews.lns.cornell.edu!newsstand.cit.cornell.edu!ngpeer.news.aol.com!feed3.newsreader.com!newsreader.com!newsfeed.news2me.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3DFBD8E8.1020604@acm.org> From: Jeffrey Carter User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: CONSTRAINT_ERROR - why? References: <3DFB7841.F898C02@t-online.de> <3DFB9276.7070809@acm.org> <3DFBB00B.230289A2@t-online.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 15 Dec 2002 02:18:53 GMT NNTP-Posting-Host: 63.184.104.31 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 1039918733 63.184.104.31 (Sat, 14 Dec 2002 18:18:53 PST) NNTP-Posting-Date: Sat, 14 Dec 2002 18:18:53 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:31838 Date: 2002-12-15T02:18:53+00:00 List-Id: Alfred Hilscher wrote: > > Jeffrey Carter schrieb: >> >>declare >> Value : constant := X'Size / 8; >>begin >> Y := Value; >>end; > > Is there no way to avoid this extra assignment? I expected something > like function "/" (Left, Right : universal_integer) return Byte; There is no "extra assignment". This is a static universal expression and is evaluated by the compiler. Value becomes a name for the resulting value (a "named number"). The block statement above is another way to write Y := 33; except that changes to X are handled automatically. This is, however, a gotcha in Ada. The context of the expression helps determine the selection ("overload resolution") of the operator. Lots of people, including experienced people, expect the universal operation to be selected for an assignment to a variable or the initialization of an object, but that's not what the language rules say. -- Jeff Carter "C++ is like giving an AK-47 to a monk, shooting him full of crack and letting him loose in a mall and expecting him to balance your checking account 'when he has the time.'" Drew Olbrich