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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b4731a3b5d591abd X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Task Discriminants & Arrays Date: 1997/05/15 Message-ID: #1/1 X-Deja-AN: 241732673 References: <3379C86F.352@this.message> <337B09C9.62BB@sprintmail.com> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-05-15T00:00:00+00:00 List-Id: In article <337B09C9.62BB@sprintmail.com>, johnvolan@sprintmail.com wrote: >An interesting suggestion. We could have something like: > > task type Process_Type > (Process_Id : Process_Id_Type := Get_New_Process_Id) > -- Note: We have to make sure this function is already > -- elaborated at this point; probably needs to be in another > -- package No. The rule that a procedure body is a "later declarative item" went away in Ada 95: declare Index : Natural := 0; function Get_New_Process_Id return Positive is begin Index := Index + 1; return Index; end; task type T (Id : Positive := Get_New_Process_Id) is entry E; end T; type TA is array (Positive range 1 .. 10) of T; O : TA; ... This kind of application is precisely why the rule went away. No more Program_Error! However, as Bob pointed out, this doesn't guarantee that O(I).Id = I. Perhaps in Ada 0X we can add loop expressions (sort of like what you have in Fortran). That would allow more initializations at the point of declaration of an object, instead of having to defer the initialization to the executable region (e.g. the begin part of the body) because the initialization requires a loop. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271