Skip to content

Commit ceb37d5

Browse files
Clarify note about eager vs. lazy evaluation (#901)
* Clarify note about eager vs. lazy evaluation * Update spec/formatting.md Co-authored-by: Addison Phillips <[email protected]> * Avoid using 'may' * Add language about writing vs. reading mutable state; add note that functions that write state are not recommended * Try again * Update spec/formatting.md Co-authored-by: Addison Phillips <[email protected]> * Split the addition into a normative part and an editorial part * Fix NOTE markup * Fix markup again * Update spec/formatting.md Co-authored-by: Addison Phillips <[email protected]> * Make language stricter and say that call-by-name is forbidden * Update spec/formatting.md Co-authored-by: Addison Phillips <[email protected]> * Another pass --------- Co-authored-by: Addison Phillips <[email protected]>
1 parent a2ef6bb commit ceb37d5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

spec/formatting.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ nor be made available to _function handlers_.
5757
> _declarations_ affecting _variables_ referenced by that _expression_
5858
> have already been evaluated in the order in which the relevant _declarations_
5959
> appear in the _message_.
60+
> An implementation MUST ensure that every _expression_ in a _message_
61+
> is evaluated at most once.
62+
63+
> [!NOTE]
64+
>
65+
> Implementations with lazy evaluation MUST NOT use a
66+
> call-by-name evaluation strategy. Instead, they must evaluate expressions
67+
> at most once ("call-by-need").
68+
> This is to prevent _expressions_ from having different values
69+
> when used in different parts of a given _message_.
70+
> _Function handlers_ are not necessarily pure: they can access
71+
> external mutable state such as the current system clock time.
72+
> Thus, evaluating the same _expression_ more than once
73+
> could yield different results. That behavior violates this specification.
74+
75+
> [!IMPORTANT]
76+
> Implementations and users SHOULD NOT create _function handlers_
77+
> that mutate external program state,
78+
> particularly since such a _function handler_ can present a remote execution hazard.
79+
>
6080
6181
## Formatting Context
6282

0 commit comments

Comments
 (0)