From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 27 Apr 92 10:59:41 GMT From: milo!svh@uunet.uu.net (Steven Hovater) Subject: Re: Procedure/function specification/declarations Message-ID: <1992Apr27.105941.12505@verdix.com> List-Id: In article <21295@hacgate.UUCP> hayes%bh_ddemo3@hac2arpa.hac.com writes: >I'm a beginner to Ada... > > >I've noticed that it is possible to specify a procedure >or function without parameters without using a >null parameter list specification. What was the thinking >behind this or why is this method superior? > >For example, in ANSI C a function prototype might be > boolean empty (void); >In Ada, a corresponding specification would be > function empty return boolean; > >Personally, I like the way C does it: function/procedure >_calls_ are always followed by a set of parentheses ( >containing data, obviously, if necessary). It seems like "Less is more", eh? Why require parenthesis to indicate that you don't have anything? >in Ada, I could come across a piece of code like this: > > if empty then > .... > endif >and I wouldn't know from the context if empty was a boolean >variable or function. Thus, if I modified the code to make >an assignment to empty (empty := FALSE) I wouldn't find out >until compile time. Well, it would take a little more than just assignment: you'd have to go out of your way to declare a boolean variable, and then make the assignment. Not likely you'd do that by accident. >>From the point of view that you wouldn't know whether it was a boolean variable or boolean function: you don't really care: you're testing a value. In the case of a variable, it's a variable's value, and in the case of a function it is the function return value. Boolean is boolean. > I do realize that this ambiguity could be argued that it >is a feature... > -- -- Steven V. Hovater (703)318-5839 Verdix Corporation svh@verdix.com