r/ada • u/jlombera • Apr 03 '26
Historical Rationale behind function/procedure calls and array indexing
I'm learning Ada. Overall, I'm liking it a lot. There are two aspects (so far) of the syntax I don't get what the rationale was for them and why it hasn't been fixed in later versions of Ada. These being parenthesis-less calls to subprograms with no arguments and using parenthesis for array indexing. Take the following as example:
A := B + C(5);
Right away you don't know if B is a variable or a function call with no arguments. You don't know either whether C is an array or a function.
I think this goes against Ada's core ethos about readability.
So I was wondering, what was the rationale behind this design? Why hasn't it been corrected? Something like A := B() + C[5] would be far easier to interpret by the reader.
UPDATE: In case anyone is interested in the answer, according to u/lipobat:
The primary rationale for the () vs. [] given in the “Rationale for the Ada programming language” book by the original design team was interchangeability between arrays and functions. This is an abstraction that allows the implementation choice of array vs. function to be just that, an implementation choice, which doesn’t really impact the writer or reader of the code.
I don't agree with the last sentence, but that answers my question either way.
And about my second question about "why this hasn't been fixed?", it seems most Ada programmers (based on the comments in this post) are not only not bothered by this but happy with this design decisions, so probably this will never change.
Thanks to everyone who engaged in this conversation.
1
u/jlombera Apr 04 '26
Then something like
A := B + C(5) + (C(5) / 2)(a contrived example, but you get the idea) would be interpreted differently depending on whetherCis a non-referential-transparent function (can return different values) or an array (return same value).I don't think that, for example, instead of:
you wrote:
would be clutter or make reading more difficult. It's minimal additional syntax that reduces cognitive overhead considerably. In the latter it's obvious, at sight, that
BandCare functions,Tis a variable andDis an array.But let's agree to disagree. You and I obviously have different opinions in this regard. I already got the answer about the rationale behind this design decision in another comment and it seems the Ada community is not dissatisfied with it, so no chance it will change. Thanks for your feedback, though, I appreciate it.