Skip to content

Commit 082a9be

Browse files
author
Damian Rouson
committed
doc: edit example/README.md
1 parent d679312 commit 082a9be

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

example/README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
-------------------------------------------
1+
Examples
2+
========
23

34
This directory contains two example programs.
45

56
Simple examples
67
---------------
78

89
The [simple_assertions.f90] example demonstrates a precondition and a
9-
postcondition, each with an assertion that checks the truth of a logical
10+
postcondition, each with an assertion that checks the truth of a logical
1011
expression based on scalar, real values.
1112

1213
Derived type diagnostic data
@@ -21,17 +22,27 @@ argument of `assert`. The generic programming facilities planned for
2122
best way to facilitate the extraction of diagnostic data from objects by
2223
empowering developers to express requirements on types such as that the types
2324
must support a specific procedure binding that can be used to extract output
24-
in character form, the form that `assert` uses for its error stop code. For
25+
in character form, the form that `assert` uses for its error stop code. For
2526
now, we impose such a requirement through an `as_character` deferred binding
2627
on the provided `characterizable_t` abstract type.
2728

28-
Because might be problematic to require that a user type to extend the
29+
Because it might prove problematic to require that a user type to extend the
2930
`characterizable_t` abstract type, the [derived_type_diagnostic.f90] example
30-
shows a workaround based on the class hierarchy described in the figure
31-
below. The pattern expressed in the workaround aggregates the example user
32-
type, `stuff_t` as a component inside the encapsulating `characterizable_stuff_t`
33-
type. The latter type extends `characterizable_t` and implements this parent
34-
type's deferred binding.
31+
shows a workaround based on the class hierarchy described in the figure below.
32+
The figure shows a Unified Modeling Language ([UML]) class diagram with the
33+
`characterizable_t` abstract class, an example user's `stuff_t` class, and a
34+
`characterizable_stuff_t` class. The pattern expressed in the workaround
35+
aggregates the example user type, `stuff_t`, as a component inside the
36+
encapsulating `characterizable_stuff_t` type defined to extend `characterizable_t`
37+
for purposes of implementing `characterizable_t` parent type's deferred
38+
`as_character()` binding.
39+
40+
The figure below also shows two constraints written in UML's Object Constraint
41+
Language ([OCL]). The constraints describe the precondition and postcondition
42+
checked in [derived_type_diagnostic.f90] and the context for those constraints.
43+
44+
The UML diagram below was generated in the [Atom] editor [PlantUML] package
45+
from the PlantUML script in this repository's [../doc/] folder.
3546

3647
![Classes involved in Derived-Type Diagnostic Example](https://user-images.githubusercontent.com/13108868/130385757-6b79e5f1-5dec-440c-98f5-0f659c538754.png)
3748

@@ -43,8 +54,8 @@ Running the examples
4354
fpm run --example simple_assertions
4455
fpm run --example derived_type_diagnostic
4556
```
46-
where the `fpm run` automatically invokes `fpm build` if necessary, .e.g., the `fpm` source has
47-
changed since the most recent build. If `assert` is working correctly, the first `fpm run` above
57+
where `fpm run` automatically invokes `fpm build` if necessary, .e.g., if the package's source code
58+
has changed since the most recent build. If `assert` is working correctly, the first `fpm run` above
4859
will error-terminate with the character stop code
4960
```
5061
Assertion "reciprocal: abs(error) < tolerance" failed on image 1 with diagnostic data "-1.00000000"
@@ -76,3 +87,7 @@ with `.false.`.
7687
[Single-image execution]: #single-image-execution
7788
[derived_type_diagnostic.f90]: ./derived_type_diagnostic.f90
7889
[simple_assertions.f90]: ./simple_assertions.f90
90+
[UML]: https://en.wikipedia.org/wiki/Unified_Modeling_Language
91+
[OCL]: https://en.wikipedia.org/wiki/Object_Constraint_Language
92+
[Atom]: https://atom.io
93+
[PlantUML]: https://plantuml.com

0 commit comments

Comments
 (0)