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 07:06:04 PST Path: supernews.google.com!sn-xit-03!supernews.com!freenix!wanadoo.fr!opentransit.net!fu-berlin.de!uni-berlin.de!b87b6.pppool.DE!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Problem trying to implement generics. Date: Sun, 15 Apr 2001 16:09:32 +0200 Message-ID: <3AD9AB9C.80405@elros.cbb-automation.de> 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: b87b6.pppool.de (213.7.135.182) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 987343541 9053538 213.7.135.182 (16 [77047]) User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0 X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:6901 Date: 2001-04-15T16:09:32+02:00 List-Id: James Rogers wrote: > 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. Why? There are lot of cases where a procedure with a result would be natural: random generator, memory allocator, table search etc. > 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 The practice is exactly the point. Take a look at Windows API. You will discover functions returning values which nobody needs and modifying parameters as well as global system state. Then I absolutely agree with you that ignoring the return value indicates a potential problem, therefore I would like to have a syntax construct for this, that will alert a code reader. Just like "unchecked_access". Moreover, I would like to have some syntax sugar for dummy [in]out parameters, but I have no idea how it cold look like. Regards, Dmitry Kazakov