[GAP] Question about subprogram syntax
Peter C. Chapin
pchapin at ecet.vtc.edu
Tue Feb 21 16:36:30 CET 2006
On Tue, 21 Feb 2006, Diego Alonso Cáceres wrote:
> I've been teaching Ada for three years now and often my students make me
> the same question: "Why don't parameter-less subprograms have empty
> brackets like C or Java? The code would be easier to read and maintain.
> It would be also possible to have a variable and a procedure with the
> same name."
>
> I really don't what to answer because I think the same. Wasn't Ada
> thought as "write once, read many times" or "Ada enhances readability"?
> Why inherit this from Pascal?
I'm not an expert but my understanding was that this is considered a
feature. The idea is that it is possible to replace a constant with a
parameterless function without editing any code that uses that constant.
A := B;
B might be a value today, but a parameterless function tomorrow. This
might be useful, for example, when it becomes necessary to do some
significant computation to obtain the desired value.
I don't know how often this actually comes up in the wild, though.
Peter
More information about the GAP
mailing list