comp.lang.ada
 help / color / mirror / Atom feed
* Re: Procedure/function specification/declarations
@ 1992-04-27 10:59 Steven Hovater
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Hovater @ 1992-04-27 10:59 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Procedure/function specification/declarations
@ 1992-04-27 15:58 yale.edu!spool.mu.edu!umn.edu!sctc.com!stachour
  0 siblings, 0 replies; 2+ messages in thread
From: yale.edu!spool.mu.edu!umn.edu!sctc.com!stachour @ 1992-04-27 15:58 UTC (permalink / raw)


svh@verdix.com (Steven Hovater) writes:

>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;
>>

  I think that the C style comes from the PL/I style.
I don't know where PL/I got the style.

  The need is to distinguish between passing a function
and calling a function.  For exmple, if I write in PL/I,
  [My PL/I is rusty, this might not be 100% right]

      DCL EMPTY_F ENTRY () RETUNRS ( ENTRY () );

and then call P, which expects to take as its first argument
a entry with no parameters, then I need to distinguish between

  1:    A = P ( EMPTY_F(), ... )
and
  2:    A = P ( EMPTY_F, ... )

In case 1, the function returned by EMPTY_F is being passed,
in case 2, EMPTY_F is being passed.

Note that any well-defined language that allows entries to be passed
as arguments needs some way of making that distinction. [No, I don't
consider C as a well-defined language, but C does allow entries
to be passed as arguments and Ada doesn't.  That's good in some
contexts and bad in others.  It's my opinion that the requirements
for Ada forbid the definition of entries being passed as arguments
based upon the horrors that were present in FORTRAN and Assembly and
... code of that day; these horrors are often also present in
poorly-designed C programs.  They are not present in poorly designed
Ada programs because they aren't possible.]


-- 
Paul Stachour          SCTC, 1210 West County Rd E, Suite 100           
stachour@sctc.com          Arden Hills, MN  55112-3739
                             [1]-(612) 482-7467

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1992-04-27 15:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-04-27 10:59 Procedure/function specification/declarations Steven Hovater
  -- strict thread matches above, loose matches on Subject: below --
1992-04-27 15:58 yale.edu!spool.mu.edu!umn.edu!sctc.com!stachour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox