Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update quick reference to show post-4.0 function syntax #5649

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/QuickReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ function Factorial(n: int): int
says that the result of `Factorial` is always positive, which Dafny verifies inductively from the function body.
To refer to the function's result in the postcondition, use the name of the function itself, as shown in the example.

By default, a function is ghost, and cannot be called from executable (non-ghost) code. To make it non-ghost, replace the keyword `function` with the keyword phrase `function method`.
After Dafny 4.0, functions are executable (non-ghost) by default, and can be made ghost by replacing the keyword `function` with the keyword phrase `ghost function`. Before Dafny 4.0, a function is a ghost by default and cannot be called from executable code. To make it non-ghost (before Dafny 4.0), replace the keyword `function` with the keyword phrase `function method`.

A function that returns a boolean can be declared with the keyword `predicate` and then eliding the colon and return type.

If a function or method is declared as a member of a type (like a `class`), then it has an implicit receiver parameter, `this`.
Expand Down