You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorial/Constructors.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ A simple class with a few data fields might have constructors that look like thi
11
11
12
12
The first constructor simply initializes the fields from the constructor's argument list. The specification for the constructor first requires that the
13
13
input values are non-negative and then simply says that after the constructor is finished, the newly constructed object's data fields equal the input
14
-
values. The heading `normal_behavior` says that the constructor does not throw any exceptions; it is discussed further [here](MultipleBehaviors).
14
+
values. The heading `normal_behavior` says that the constructor does not throw any exceptions; it is discussed further [here](MultipleBehaviors#SpecializedBehaviors).
15
15
There is also the modifier `pure`; more on that below.
16
16
17
17
The second constructor is similar to the first. The specification is perhaps less obvious because of the constructor call (the `this` call) of the first
Copy file name to clipboardExpand all lines: tutorial/MultipleBehaviors.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ There are a few points to note:
21
21
* There is no order to the behaviors; they can be written in any order that is understandable.
22
22
* Every behavior applies on its own and must hold by itself --- there is no if-then-else among them. If a behavior's preconditions hold,
23
23
then its postconditions must hold, independent of what any other behavior says.
24
-
* The effective precondition for each behavior is the conjunction (with `&&`) of the preconditions for that behavior. The effective precondition for the combination of multiple behaviors is the disjunction (with `||`) of the effective preconditions of the individual behaviors. Consequently, at the point where such a method is called, at least one, but by no means necessarily all, of the behaviors must have an effective precondition that is true.
24
+
* The effective precondition for each behavior is the conjunction (with `&&`) of the preconditions for that behavior. The effective precondition for the combination of multiple behaviors is the disjunction (with `|`) of the effective preconditions of the individual behaviors. Consequently, at the point where such a method is called, at least one, but by no means necessarily all, of the behaviors must have an effective precondition that is true.
25
25
26
26
In our example, if `a`, `b`, and `c` are all equal, then the precondiition (`requires` clause) of each of the three behaviors is true.
27
27
So the postconditions of each of the behaviors must also be true. Fortunately they all agree.
@@ -67,18 +67,18 @@ The normal and exceptional behaviors illustrated in the previous section are ver
67
67
The `normal_behavior` heading implies that no exception is allowed (`signals false`); the `exceptional_behavior` heading says that normal termination is not allowed (`ensures false`).
68
68
A behavior that is neither of these is a simple `behavior`, which is the default when there is no heading.
69
69
70
-
One other point: any one of the behavior keywords needs a visibility keyword; almost always, as in the example above, the visibility is the same as the method. The absence of a visibility modifier means `package` visibility, just as the absence of a visibility modifier on the method declaration. However, if there is no specialized behavior keyword, then there is no place for the visibility keyword; in that cae, the visibility is the same as the visibility of the method.
70
+
One other point: any one of the behavior keywords needs a visibility keyword; almost always, as in the example above, the visibility is the same as the method. The absence of a visibility modifier means `package` visibility, just as the absence of a visibility modifier on the method declaration. However, if there is no specialized behavior keyword, then there is no place for the visibility keyword; in that case, the visibility is the same as the visibility of the method.
71
71
72
-
## Summary of specification cases
72
+
## <aname="SpecializedBehaviors"></a>Summary of specification cases
73
73
74
74
To summarize, a method may have multiple specification cases.
75
75
* They are separated/connected by the `also` keyword.
76
76
* Each specification case consists of an optional heading followed by a series of method specification clauses
77
-
* There are four styles of headings. Here `V` is a visibility modifier: one of `public`, `protected, `private`, or absent, meaning package visibility
77
+
* There are four styles of headings. Here `V` is a visibility modifier: one of `public`, `protected`, `private`, or absent, meaning package visibility
78
78
* The most general: `V behavior`
79
79
* Normal exit only: `V normal_behavior`
80
80
* Exit by exception only: `V exceptional_behavior`
81
-
* The most common: no heading, which means `V behavior` with the visibility `V` being the same as the method's visibilty
81
+
* The most common: no heading, which means `V behavior` with the visibility `V` being the same as the method's visibility
0 commit comments