Skip to content

Commit f12047a

Browse files
Update declarations.md (#988)
Signed-off-by: Neil Henderson <[email protected]>
1 parent d3b6575 commit f12047a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/cpp2/declarations.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ All Cpp2 declarations are written as **"_name_ `:` _kind_ `=` _statement_"**.
1414

1515
> Note: When the type is omitted, whitespace does not matter, and writing `#!cpp x: = 0;` or `#!cpp x : = 0;` or `#!cpp x := 0;` or other whitespace is just a stylistic choice. This documentation's style uses the last one, except when there are multiple adjacent declaration lines this style lines up their `:` and `=`.
1616
17+
> Note: The only variation to the above is that 'constexpr' functions are written with `==` instead of `=` (e.g., `#!cpp square: (i: int) == i * i;`).
1718
1819
## Examples
1920

@@ -58,6 +59,9 @@ n: namespace
5859

5960
// color is an @enum type (see Note)
6061
color: @enum type = { red; green; blue; }
62+
63+
// a constexpr function is defined with `==`
64+
calc_next_year: (year: i32) -> i32 == { return year + 1; }
6165
}
6266
```
6367

0 commit comments

Comments
 (0)