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-15 04:46:04 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed.icl.net!diablo.netcom.net.uk!netcom.net.uk!not-for-mail From: "Ayende Rahien" Newsgroups: comp.lang.ada Subject: Re: Problem trying to implement generics. Date: Sun, 15 Apr 2001 14:20:07 +0200 Organization: (Posted via) GTS Netcom - Public USENET Service http://pubnews.netcom.net.uk Sender: ayende@softhome.net Message-ID: <9bc1lb$o1$1@taliesin.netcom.net.uk> 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> <3AD915C2.321EB048@worldnet.att.net> NNTP-Posting-Host: diup-181-143.inter.net.il X-Trace: taliesin.netcom.net.uk 987335148 769 213.8.181.143 (15 Apr 2001 11:45:48 GMT) X-Complaints-To: abuse@corp.netcom.net.uk NNTP-Posting-Date: Sun, 15 Apr 2001 11:45:48 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.60.2296.0000 X-MimeOLE: Produced By Microsoft MimeOLE V5.60.2296.0000 Xref: supernews.google.com comp.lang.ada:6898 Date: 2001-04-15T14:20:07+02:00 List-Id: "James Rogers" wrote in message news:3AD915C2.321EB048@worldnet.att.net... > 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. I thought that they added exceptions because of this type of functions: int & Foo(); Where there is no return value that you can use for errors. For the rest, I agree. > 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