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-Thread: a07f3367d7,3867e2f73fa21ec X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.224.217.195 with SMTP id hn3mr6080101qab.5.1367429278054; Wed, 01 May 2013 10:27:58 -0700 (PDT) X-Received: by 10.50.153.101 with SMTP id vf5mr439963igb.11.1367429277830; Wed, 01 May 2013 10:27:57 -0700 (PDT) Path: ef9ni40844qab.0!nntp.google.com!s14no1700367qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 1 May 2013 10:27:57 -0700 (PDT) In-Reply-To: <7704abab-86f2-4edc-ad4b-b3d4e70004fb@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.20.190.126; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 69.20.190.126 References: <7704abab-86f2-4edc-ad4b-b3d4e70004fb@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Ada 2012: In-out parameters for functions From: Shark8 Injection-Date: Wed, 01 May 2013 17:27:58 +0000 Content-Type: text/plain; charset=ISO-8859-1 Date: 2013-05-01T10:27:57-07:00 List-Id: On Wednesday, May 1, 2013 10:28:07 AM UTC-6, dpt...@arcor.de wrote: > > So, when do I use functions or procedures. Functions have return values. Any other differences? Not really. Though a function w/ out parameters could be used like this: -- Given Recognize(P : Pattern, S : String, O : out Object_Type) Return Boolean if Recognize( Pattern_1, Input, Object ) then -- process object elsif Recognize( Pattern_2, Input, Object ) then -- process object end if; Another thing is that functions can output unconstrained types [but the result is constrained], which means they can be used to assign to arrays or tagged-type 'CLASSes or the or discriminated types. So we could now have a tokenizer like this: -- Token_List: Vector containing the type Token. Function Tokenize(Input : String) Return Token_List is -- Nested Tokenize consumes a portion of the string and returns a token. Function Tokenize(Input : in out Unbounded_String) Return Token with pre => Length(Unbounded_String) > 0; [...] Working : Unbounded_String:= To_Unbounded_String( Input ); begin Return Result : Token_List do while Length(Working) > 0 loop Result.Append( Tokenize(Working) ); end loop; End return; end Tokenize;