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.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bc2c82b1e5c6fe83 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.204.150.90 with SMTP id x26mr608751bkv.6.1330218977416; Sat, 25 Feb 2012 17:16:17 -0800 (PST) Path: t13ni70323bkb.0!nntp.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 25 Feb 2012 19:16:14 -0600 Date: Sat, 25 Feb 2012 20:16:04 -0500 From: "Peter C. Chapin" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Question about out parameters of unconstrained array type. References: In-Reply-To: Message-ID: <4NedncPWdPN9GtTS4p2dnAA@giganews.com> X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-B5h3Ch9But7sDdwKVCSRgyaAjFQhw3SzY9f5zZT0vAJRASSzw54xiSCfrTPFnD8oe4ViJTcZwPVT0fx!o5TRw0bDPflStgEQDttqRzADMEz6D2LxLK1LLYijJiomnT5iZYpOhSgyWfijafA= X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html 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.3.40 X-Original-Bytes: 3176 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-02-25T20:16:04-05:00 List-Id: On 2012-02-25 13:20, Phil Thornley wrote: > I think that you may be misinterpreting the SPARK error message: > > 15 for I in 1 .. S'Length loop > ^ > *** Syntax Error : reserved word "IN" cannot be followed by > INTEGER_NUMBER here. > > The error here is that the loop index has an anonymous subtype. I'm sorry to have distracted you with my silly error. That's what happens when one just types some code into a posting off the top of one's head. My real code is more like this: procedure Get_Event (Date : in Dates.Date; Description : out String; Status : out Status_Type) --# global in Event_Array; --# derives Description from Event_Array, Date & --# Status from Event_Array, Date; is I : Event_Index_Type; begin Status := No_Event; Description := (others => ' '); -- NOTE HERE [1] I := Event_Index_Type'First; loop -- Is this item in the event array the one we are looking for? if Event_Array(I).Date = Date then -- NOTE HERE [2] if Description'Length < Event_Array(I).Description_Size then Status := Description_Too_Long; else -- Copy Event_Array(I).Description_Text into Description Status := Success; end if; exit; end if; -- If not, then advance to the next item. exit when I = Event_Index_Type'Last; I := I + 1; end loop; end Get_Event; Without the initialization at [1] the use of Description'Length at [2] produces the error Alexander mentions: "Expression contains reference(s) to variable Description which has an undefined value." However with the initialization at [1] this error goes away. Thus it appears that SPARK requires that the initial value be defined before it will let you use the attributes. Peter