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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Procedure vs function Date: Fri, 05 Sep 2014 23:25:40 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <9032a6f8-57ea-490c-bab0-2d0624eede00@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Sat, 6 Sep 2014 06:25:42 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="5b4eadb0ecf28f7f740a0e18f3715b8f"; logging-data="9882"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+OFLtWwGa0txhxbfkwiWCK5bSyiM9gBN0=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 In-Reply-To: Cancel-Lock: sha1:KWEa59Bsx51BXAijhrlqO/eR4u8= X-Original-Bytes: 2577 Xref: number.nntp.dca.giganews.com comp.lang.ada:188892 Date: 2014-09-05T23:25:40-07:00 List-Id: On 09/05/2014 10:44 PM, Niklas Holsti wrote: > > In a nutshell: the only difference between a function subprogram and a > procedure subprogram is that a function call returns a value, from a > "return " statement inside the function, and therefore a > function call can (and must) be used as part of an expression, not as a > stand-alone statement. Another significant difference is that the value returned from a function can have constraints not known by the caller when the call is made, while any values returned from procedures go into the actual parameters of "[in] out" parameters, which must be variables, and hence have constraints imposed by the caller. Compare the function and procedure versions of Ada.Text_IO.Get_Line. With the function version declare S : String := Ada.Text_IO.Get_Line; S can have any length and the line terminator will always be skipped. With the procedure version declare S : String (1 .. N); L : Natural; begin Ada.Text_IO.Get_Line (Item => S, Last => L); S'Length = N. If the line contains more then N characters, only N will be placed in S, and the line terminator will not be skipped. -- Jeff Carter "It's all right, Taggart. Just a man and a horse being hung out there." Blazing Saddles 34