Open Entomy opened 4 years ago
This could further take advantage of #18 and present the following:
function Arithmetic_Mean(values : params Integer[]) return Integer;
and then:
Average : Integer := Arithmetic_Mean(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
Q. Does this encourage the hard-coding of integer literals deep inside code, where perhaps it would be better served with enumeration types or predicates?
No, this is just the equivalent of C's:
int[] values;
Here, int[]
is an anonymous array, since we never gave it a formal name through a typedef
.
In either case it doesn't actually change what the programmer is able to do. It just avoids the need a formal type name when it's not necessary.
Should Support:
(using the syntax of #8)
Rationale:
Oftentimes we don't need a nominatively discriminated array type, and just want to define a function or operator for any array of a specific type. Adding in anonymous arrays wouldn't take away the cases where nominative discrimination is desired, and would merely make things easier on library maintainers and consumers, since they wouldn't need to provide and instantiate generics for what is literally not varying in any regards other than name. This makes Ada far more suitable to rapid development.