1 / 33

Packages

Packages. Presented by Quentin Ochem. university.adacore.com. The Ada Package. A package is the base of software architecture in Ada It ’ s a semantic entity checked by the compiler It separates clearly a specification and an implementation. General Structure of a Package.

jacob-byers
Télécharger la présentation

Packages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Packages Presented by Quentin Ochem university.adacore.com

  2. The Ada Package • A package is the base of software architecture in Ada • It’s a semantic entity checked by the compiler • It separates clearly a specification and an implementation

  3. General Structure of a Package • Entities should be put in the body except if they have to be exported • The body is easier to change than the specification

  4. Example

  5. Accessing components of a package • Only entities declared in the public part are visible • Entities are referenced through the dot notation

  6. Child units • A child unit is an extension of a package • Can be used to organize the namespace or break big packages into pieces • Child units have visibility over parents • Generally speaking, it’s a good habit to break functionality into packages as much as possible

  7. Full dependencies (“with clause”) • “With clause” defines a dependency between two packages • Gives access to all the public declarations • Can be applied to the spec or the body • A dependency is normally done to a specification • “Specification with” applies to the body • “Specification with” applies to children • There is no other transitivity

  8. About the usage of the "with" keyword • With is a highly overloaded Ada reserved word • It can be used to declare a dependency between two units • It can be used to introduce an aspect • It can be used to extend a record • … and others situations as well

  9. Dependency shortcut (“use clause”) • Prefix may be overkill • The “use clause” allows omitting it • Can introduce ambiguities • Can be placed in any scope

  10. A Note about Operator Symbol Visibility • With only a “with” clause, operators on types will not be visible! • Use type will specifically allow visibility to operators of a type • Prefix notation is possible too

  11. A Package is a High Level Semantic Entity • The compiler is responsible for checking structural and semantic consistency

  12. (1/10)

  13. (1/10) compilation error Read is not implemented in the body

  14. (2/10)

  15. (2/10) compilation error a body can't be written in a package spec

  16. (3/10)

  17. (3/10) compilation error "with P1;" is needed on P2 for the declaration to work

  18. (4/10)

  19. (4/10) compilation error T is declared in the body of P1, not reachable from the outside

  20. (5/10)

  21. (5/10) compilation error there is a circularity between P1 and P2

  22. (6/10)

  23. (6/10) there is no circularityP1 depends only the spec of P2 the body of P2 depends on the spec of P1

  24. (7/10)

  25. (7/10) compilation error operators are not reachable for the lack of use clause on "Types" package

  26. (8/10)

  27. (8/10) no errors a child package has use-visibility over its parent

  28. (9/10)

  29. (9/10) a child always depends on its parent this create a circularity here

  30. (10/10)

  31. (10/10) no error the body of P1 depends on the specification of P1.Child

More Related