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,72c34c66b38e0e05 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-02 11:44:11 PST From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Proposal: Constructors, Assignment [LONG] Date: Thu, 2 Jan 2003 13:44:42 -0600 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: abuse@supernews.com Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!fr.clara.net!heighliner.fr.clara.net!news-raspail.gip.net!news.gsl.net!gip.net!news.rosprint.net!news3.cnt.ru!sn-xit-03!sn-xit-06!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail Xref: archiver1.google.com comp.lang.ada:32458 Date: 2003-01-02T13:44:42-06:00 List-Id: Dmitry A. Kazakov wrote in message ... >Randy Brukardt wrote: >I suppose it will be allowed for all types? Then it would be interesting to >know how it will work with by-value types: > >function Set_Bit (Value : Boolean) return Boolean is > Result : return Boollean := Value; >begin > return Result; >end Set_Bit; > >... provided that the result is an element of a packed array. Somehow, >somewhere the "in-place" requirement have to be relaxed. I wonder how many >pages one will add to RM. I don't know, it wasn't my idea. I'd suspect that by-copy types would be handled by-copy, thus you couldn't tell if it was in-place or not. >Then there will be much work required to deal with things like: > >function Make_Session (Count: Integer) return Internet_Session is >begin > declare > Result1 : return Internet_Session (24); > begin > if ... then > return Result1; > end if; > end; > declare > Result2 : return Internet_Session (1000); - another size > begin > if ... then > return Result2; > end if; > end; > declare > Result3 : Internet_Session (10); -- I forgot "return" > begin > return Result3; > end; >end Make_Session; No, this is illegal. There can only be one result object declared. And if there is one, returning anything else is illegal. So the declaration of Result2 and the return of Result3 are illegal. >I am not sure, but to determine whether there is only one result, could be >equivalent to halting problem. So some sort of run-time support will be >well required to determine this. Or will it be classified as one more bound >error? No, these are all compile-time checks. No run-time penalty at all. Indeed, this is cheaper than Ada 95, where there is a run-time check that the result of a function is "accessible". (And that check prevents doing much useful with the function.) Randy.