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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1042f393323e22da X-Google-Attributes: gid103376,public From: "John G. Volan" Subject: Re: Any research putting c above ada? Date: 1997/05/12 Message-ID: <3376EA02.3269@sprintmail.com>#1/1 X-Deja-AN: 241039628 References: <208C9C61CA05C32B.65D82DC950AAA33A.D68E7B27EB42E98A@library-proxy.airnews.net> <3372D44E.5F44@sprintmail.com> Organization: Sprint Internet Passport Reply-To: johnvolan@sprintmail.com Newsgroups: comp.lang.ada Date: 1997-05-12T00:00:00+00:00 List-Id: Kevin Cline wrote: > > I didn't say you would RETURN a reference to a container. > I said you would pass one. I jumped into this thread a little late. But it looked like you said this in a context where to were talking about extra copying happening on return from a function... > "John G. Volan" wrote: > > >...So don't turn your nose up so fast about the return-by-copy mechanism in > >Ada95 (or in C++ for that matter). Sure, you lose some efficiency, but > >you get a lot of safety from that! > > In C++, you would write something like: > > void Read_File_Lines(vector& lines, istream& in) You can most certainly do something analogous in Ada95: package Line_Vectors is new Vectors (Unbounded_String); procedure Read_File_Lines (Input_Stream : in out Input_Stream_Type; -- whatever that is Line_Vector : in out Line_Vectors.Vector_Type); Now, assuming that Vector_Type is either limited or tagged (or both), you are guaranteed that it will be passed by reference, not by copy. ------------------------------------------------------------------------ Internet.Usenet.Put_Signature (Name => "John G. Volan", Home_Email => "johnvolan@sprintmail.com", Slogan => "Ada95: The World's *FIRST* International-Standard OOPL", Disclaimer => "These opinions were never defined, so using them " & "would be erroneous...or is that just nondeterministic now? :-) "); ------------------------------------------------------------------------