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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dab7d920e4340f12 X-Google-Attributes: gid103376,public From: adam@irvine.com (Adam Beneschan) Subject: Re: Ada is 'better' than C because... Date: 1996/07/30 Message-ID: <4tlhnd$v5q@krusty.irvine.com>#1/1 X-Deja-AN: 171139135 references: <01bb7bf9$b89a1740$96ee6fcf@timhome2> <4tj43k$16r@newsbf02.news.aol.com> organization: /z/news/newsctl/organization newsgroups: comp.lang.ada Date: 1996-07-30T00:00:00+00:00 List-Id: rogoff@sccm.stanford.edu writes: >I agree that Ada is better than C, however, I have always been puzzled by the >distinction in Ada between functions and procedures, which I view as an >unnecessary relic of Pascal. Why not just allow procedures which return >things? This question has, in the past, led to a religious war on comp.lang.ada almost as great as "Which is the one true language?" I don't remember all the arguments on both sides. However, I'd recommend reading Bertrand Meyer's _Object-Oriented Software Construction_, which makes a case for keeping the two concepts separate. Put simply, in Meyer's view, procedures tell an object to DO SOMETHING, while functions ASK SOMETHING of an object. Functions, therefore, should be pure query operations that don't change anything and will therefore return the same result if you call the function several times in succession. In Eiffel, Meyer's language, there is no such thing as an IN or IN OUT parameter; procedures are not allowed to return any values (but they may change the state of the object). Even with this conceptual distinction, I suppose you could define both "functions" and "value-returning procedures" in the language (as an early Ada draft did). However, they would appear syntactically identical when you called the function or procedure, making it non-obvious whether you're calling a function that does something interesting on the side or not. One last comment: one could also consider value-returning procedures to be a "relic" of assembly language, in which you write a subroutine that performs some action and returns a status value in the accumulator register. This is sort of how UNIX system calls strike me. -- Adam --- DWARF STABS ELF Film at 11