Skip to content

Document top-level do behavior#732

Open
kovan wants to merge 1 commit intoclojure:masterfrom
kovan:docs/do-top-level
Open

Document top-level do behavior#732
kovan wants to merge 1 commit intoclojure:masterfrom
kovan:docs/do-top-level

Conversation

@kovan
Copy link
Copy Markdown

@kovan kovan commented Mar 14, 2026

Adds a note to the do special form documentation explaining that at the top level, each expression is evaluated as a separate top-level form. This means side effects like require are visible to the compiler when processing subsequent expressions.

Includes a code example demonstrating the behavior and a note that this does not apply to do forms nested inside other forms.

Verified against Compiler.java eval() method: after macroexpanding, if the form is a do, each sub-form is recursively eval'd individually rather than compiled as a single unit.

Fixes #723

When do appears at the top level, each expression is evaluated as a
separate top-level form, so side effects like require are visible to
the compiler when processing subsequent expressions. This is known
as the Gilardi scenario.

Fixes clojure#723
@puredanger
Copy link
Copy Markdown
Member

Author is not a contributor and this appears to be AI generated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document do behavior at top-level

2 participants