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,ad988eb0a9545c86 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-14 20:30:01 PST Path: supernews.google.com!sn-xit-03!supernews.com!newsfeed.wirehub.nl!news.stealth.net!204.127.161.2.MISMATCH!wn2feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3AD915C2.321EB048@worldnet.att.net> From: James Rogers X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Problem trying to implement generics. References: <9b46dr$cd8$1@taliesin.netcom.net.uk> <9b6jtu$4is$2@taliesin.netcom.net.uk> <9b6m27$68e$1@taliesin.netcom.net.uk> <0JBB6.10484$FD1.1197250@news6-win.server.ntlworld.com> <9b7tce$laf$2@taliesin.netcom.net.uk> <9b85fj$25r$1@taliesin.netcom.net.uk> <3AD858A3.3070803@elros.cbb-automation.de> <9b9qjc$nk9$1@taliesin.netcom.net.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sun, 15 Apr 2001 03:27:59 GMT NNTP-Posting-Host: 12.74.156.131 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 987305279 12.74.156.131 (Sun, 15 Apr 2001 03:27:59 GMT) NNTP-Posting-Date: Sun, 15 Apr 2001 03:27:59 GMT Organization: AT&T Worldnet Xref: supernews.google.com comp.lang.ada:6897 Date: 2001-04-15T03:27:59+00:00 List-Id: Ayende Rahien wrote: > > "Dmitry A. Kazakov" wrote in message > news:3AD858A3.3070803@elros.cbb-automation.de... > > Well, but what I still cannot understand, what is the objection against > > *procedures* returning a value: > > Because that is the difference between functions & procedures? > If you wanted it that way, you could do this: > function Foo(...) return nothing; > > But I agree that it would be nice to be able to ignore function's return > value. A procedure may modify parameters, but may not return a value. The practice in C, C++, and Java of ignoring return values from functions or methods may seem very convenient. In fact it is a fundamental violation of the contract defined for a function. This is the single greatest reason exceptions were added to C++, and included from the start in Java. A common C programming paradigm is to have a function return an indication of success or failure. That same function may also modify some or all parameter values. It is also very common in C to ignore the return value of a function. What is the obvious problem? If the return value indicates success or failure, and that value is ignored, then the programmer is ensuring erroneous execution. Whenever the function fails, the programmer using that function continues to use the modified parameter values as though the function succeeded. This usually leads to very difficult debugging sessions because the error may not become obvious in the program until some later code block. It also relies upon the sometimes lucky choice of test cases to generate the error condition. If your test cases do not generate the error, then you will release erroneous code to your customer, which they will find for you, usually at significant expense for your company. In Ada you have a very strong contract concerning procedures and functions. Functions always return a value. That value has significant meaning. It cannot be ignored. Procedures are the form of subprogram to use when no significant value is to be returned. Jim Rogers Colorado Springs, Colorado USA