4 ms·
I work with Ada professionally and there's a lot to love about it. However, I have one big gripe that constantly gives me problems. It has nothing to do with th
by CivBase 5y ago
I work with Ada professionally and there's a lot to love about it. However, I have one big gripe that constantly gives me problems. It has nothing to do with the myths in the articles, but it's rare that I get to talk about this language so I'm taking my opportunity.
Ada's syntax makes differentiating variables/arrays from functions unnecessarily difficult. This is because parentheses are used for both function calls and array accesses. And function calls without parameters do not require parentheses at all.
Lets play a game. See if you can figure out which is a variable, array, or function.
A := B;
C := D;
E := F(G);
H := I(J);
A, B, C, E, H, and J are variables. F is an array. D, G, and I are functions.
The only way to really tell what's what in many cases is to look up definitions. That would be fine... except there is very little competition for Ada IDEs. I use AdaCore's GNAT Pro Studio (GPS), but the interface is clunky and often very slow compared to modern JetBrains IDEs.
This syntax issue is a constant frustration and it's something which could have very easily been avoided.
- Lucretia9 5y ago> but it's rare that I get to talk about this language comp.lang.ada, reddit.com/r/ada, irc, gitter, telegram, etc. > A, B, C, E, H, and J are variables. F is an array. D, G, and I are functions. That was by design, because when it was designed, ide's like we have now didn't exist so being able to change a variable to an array from a function or vice versa was made easier. There is another reason and that mathematically an array is a function.
- CivBase 5y ago> comp.lang.ada, reddit.com/r/ada, irc, gitter, telegram, etc. Yeah, but I don't want to join a community just to make a single complaint about a 40 year old language. > That was by design, because when it was designed, ide's like we have now didn't exist so being able to change a variable to an array from a function or vice versa was made easier. What a bizarre decision for a language built around such a strict and elaborate type system. I'd consider it being difficult to swap functions and variables to be a feature.
- egberts1 5y agoHence the strong need to suffix the variable name to denote what type the variable is.
- int_19h 5y agoWhy would you care, though? An array is effectively a function that maps indices to values, so why not reuse the syntax? And it's not like Ada is the only one that made that choice - FORTRAN, BASIC, PL/I are some other examples. If anything, I'd say that the missed opportunity was to make arrays compatible with function access types.