Skip to content

SideEffectFree and lambdas (documentation review) - #8109

Draft
smillst wants to merge 5 commits into
typetools:masterfrom
smillst:siddeffectfree-spec
Draft

SideEffectFree and lambdas (documentation review)#8109
smillst wants to merge 5 commits into
typetools:masterfrom
smillst:siddeffectfree-spec

Conversation

@smillst

@smillst smillst commented Sep 8, 2026

Copy link
Copy Markdown
Member

This is the specification I intend to implement. I want to get your approval before finishing up the code. (I'll merge these changes in another branch with the actual code changes.)

smillst and others added 3 commits September 8, 2026 08:38
Bring the Purity Checker chapter in line with the @SideEffectFree javadoc:
creating a lambda or a local/anonymous class is not a side effect, a
lambda's body is checked against the functional method's annotations, and
@SideEffectFree on a method with a functional-interface parameter is also a
requirement on that method's callers.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XCfsNnTrse2emqZorUyFej
@smillst smillst changed the title SideEffectFree and lambdas SideEffectFree and lambdas (documentation review) Sep 8, 2026

@mernst mernst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review my changes, in addition to the comments in this pull request. Thanks.


\subsectionAndLabel{Functional-interface parameters}{purity-functional-interface-parameters}

For a side-effect-free method, the default type is \<@SideEffectFree> for any

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is written with a heavy emphasis on side-effect-free methods -- so much so that I suggested changing the subsection title. I think that is a red herring. There can be a small subsubsection about defaulting for function-interface parameters of side-effect-free methods. But overall the focus should be on side-effect-free functional-interface parameters, no matter what kind of method declares them.

governs both the call in the body and the obligation on the argument,
exactly as for any other method.

Suppose that \<sem> is a \<@SideEffectFree> method or constructor with a

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the antecedents of referents hard to determine. Giving them names, such as sem here, will clarify the writing.

\item
If the argument is a lambda, its body is checked directly and no
annotation on it is needed.
\item

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are items 2 and 3 not special cases of item 4?

@mernst mernst assigned smillst and unassigned mernst Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants