3 ms·
So it's somewhat inaccurate that GP calls it an "interface", it's a specification. Ada packages have two parts: specification and implementation. The specificat
by Jtsummers 5y ago
So it's somewhat inaccurate that GP calls it an "interface", it's a specification. Ada packages have two parts: specification and implementation. The specification isn't really comparable to Java or C# interfaces and I don't think they're comparable to Rust traits either. Nor is it like typedef'ing a function pointer. The better analog is C's header files containing declarations, but not definitions, which are then implemented in various C files. A major contrast with C is that Ada's packages are named scopes and occur in pairs of spec/body, whereas in C you could have one header that is implemented over many C files, or one C files that implements many headers.
And like C header files, the range of things you can declare in a package spec is essentially any valid thing in the language: types, variables, functions, procedures, more packages, tasks, etc. But C permits the definition and declaration of anything to be in the header file, there are restrictions on Ada package specifications in that regard (some things have to go in a package body). C header `#include` order also matters (since they're text inclusion, a conflict in definitions or the use of macros can impact the outcome), whereas the `with`ing of Ada packages can be done in any order.
- pyjarrett 5y agoA good description, and this is described in the video that all of these comments are about. :P