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,595cecf596072e80 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!news.moat.net!border1.nntp.sjc.giganews.com!nntp.giganews.com!local1.nntp.sjc.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 31 May 2004 22:57:46 -0500 Date: Mon, 31 May 2004 23:57:45 -0400 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Why I like Ada References: <058ta057iumjnbj5cbdpcskvjb39vmtt2h@4ax.com> <40af5f9d$0$255$edfadb0f@dread16.news.tele.dk> <_bLrc.93133$dP1.296024@newsc.telia.net> <2hj035Fde12lU1@uni-berlin.de> In-Reply-To: <2hj035Fde12lU1@uni-berlin.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.90.114 X-Trace: sv3-2Pyg7axxcG8fACSg5YDsXkzw85uB0ZC5tT6DZ5jbmnzm7TlN2xAS72OcoA3zU3cqP6svpSU3TMhho0x!fExCxvyvo9cQCseh4sYQaHCU5P/6Lep8l8aSjd6B9sFVqCEpN1+awC3pgkPo7w== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: controlnews3.google.com comp.lang.ada:980 Date: 2004-05-31T23:57:45-04:00 List-Id: Peter Amey wrote: >> ...and the difficulty of the instantiation for Unchecked_Conversion >> might give you a clue. (The formal result type of >> Unchecked_Conversion is Target. So if you want to convert to a >> (local) type Target, you have to use selected notation... ;-) >> > > What, as in: "My.Foot"? Yes, that would concentrate the mind a bit. No, you could "get away" with function To_Target is new Ada.Unchecked_Conversion (Source => Body_Part_Type, Target => Gun.Target) I was commenting that you need to use selected notation for the type Target. Some Ada terminology is titillating, but in this case it is just scary. Hmmm. In fact... with Ada.Unchecked_Conversion; procedure Shoot_Foot is type Target is new Character; -- just so this test will compile. type Weapon is (M15A3, AK47, M1911A1); type Condition is (Healthy, Damaged, Missing); type Body_Part is record State: Condition := Healthy; -- ... end record; type Person_Body is record Head, Neck, Left_Shoulder, Right_Shoulder, Chest, Torso, Left_Arm, Right_Arm, Left_Hand, Right_Hand, Left_Leg, Right_Leg, Left_Knee, Right_Knee, Left_Foot, Right_Foot: Body_Part; end record; procedure Shoot(What: in Target; Gun: in Weapon) is begin null; end; --TBD. function To_Target is new Ada.Unchecked_Conversion (Source => Body_Part, Target => Target); Me: Person_Body; begin Shoot(To_Target(Me.Left_Foot), AK47); end Shoot_Foot; I'll be darned! GNAT took that Target => Target. I was expecting it to require the second Target to use selected notation. Its midnight, so I'll wait 'til tomorrow to figure out if that is really a bug. Of course, in reality, Target would be an in out parameter to Shoot, or an access value denoting the actual Target. (Same for gun, that's why Shoot is TBD. ;-) -- Robert I. Eachus "The terrorists rejoice in the killing of the innocent, and have promised similar violence against Americans, against all free peoples, and against any Muslims who reject their ideology of murder. Their barbarism cannot be appeased, and their hatred cannot be satisfied. There's only one way to deal with terror: We must confront the enemy and stay on the offensive until these killers are defeated." -- George W. Bush