Skip to content

docs: explain Risor vs Starlark callable-return divergence#140

Merged
robbyt merged 2 commits into
mainfrom
claude/review-repo-improvements-NDaxm
May 20, 2026
Merged

docs: explain Risor vs Starlark callable-return divergence#140
robbyt merged 2 commits into
mainfrom
claude/review-repo-improvements-NDaxm

Conversation

@robbyt
Copy link
Copy Markdown
Owner

@robbyt robbyt commented May 20, 2026

Summary

Documents the intentional divergence between Risor and Starlark in how a callable-returning script is handled. No behavior change.

The divergence:

Engine Final value is a callable Rationale
Risor Errors with "function object returned from script: ..." Expression-oriented; a trailing lambda is a legitimate value to return. Auto-call would guess at arity/args.
Starlark Auto-invokes with no args No top-level expression statement; scripts end in def by convention. Auto-call provides "run my main()" ergonomics.
Extism N/A The WASM entry-point is the function; scripts don't produce callable values.

Changes:

  • engines/README.md — new ## Script Return Value Handling section between ## Engine-Specific Data Handling and ## Data Provider Patterns, with one sub-section per engine plus a "Why they differ" coda.
  • engines/risor/evaluator/evaluator.go — brief comment above the case "function": branch pointing to the README section.
  • engines/starlark/evaluator/evaluator.go — brief comment above the starlarkLib.Callable branch with the same pointer.
  • CHANGELOG.md[Unreleased] > Documentation entry.

Existing tests already cover both behaviors:

  • Starlark auto-call: engines/starlark/evaluator/evaluator_test.go:437-457 (the _ = boom pattern)
  • Risor error: engines/risor/evaluator/evaluator_test.go:615-629 (the x => x + 1 pattern)

This closes the "Function-case alignment" backlog item as intentional divergence, documented.

Test plan

  • go build ./... clean
  • go vet ./... clean
  • go test -count=1 ./engines/risor/evaluator/ ./engines/starlark/evaluator/ green
  • CI: SonarQube, dependency-review, Copilot review

https://claude.ai/code/session_01C61VEAmjxSnX5Xhbab8NvL


Generated by Claude Code

Risor errors when a script's final value is a callable
("function object returned from script: ..."); Starlark auto-invokes a
trailing callable with no args. The two behaviors are intentional and
reflect each host language's idiom:

- Risor is expression-oriented (top-level expressions are normal), so a
  trailing function value is a legitimate result; auto-call would guess
  at arity.
- Starlark has no top-level expression statement, so scripts end in a
  `def` block by convention; auto-call provides the "run my main()"
  ergonomics the language otherwise lacks.

Adds a new "Script Return Value Handling" section to engines/README.md
and brief rationale comments at the two divergence sites. No behavior
change.

https://claude.ai/code/session_01C61VEAmjxSnX5Xhbab8NvL
Copilot AI review requested due to automatic review settings May 20, 2026 02:40
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR documents the intentional divergence between the Risor and Starlark engines when a script’s “final value” is callable, and adds small in-code pointers to the new documentation. No runtime behavior is changed.

Changes:

  • Added an engines/README.md section describing per-engine script return value handling (incl. rationale for divergence).
  • Added short comments in both evaluators pointing readers to the new documentation section.
  • Added an [Unreleased] changelog entry under Documentation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
engines/starlark/evaluator/evaluator.go Adds a comment explaining the intentional Starlark callable auto-invoke behavior and links to the docs.
engines/risor/evaluator/evaluator.go Adds a comment explaining the intentional Risor callable-as-error behavior and links to the docs.
engines/README.md Introduces “Script Return Value Handling” section documenting the divergence and rationale.
CHANGELOG.md Adds an Unreleased Documentation entry for the new docs/comments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread engines/README.md Outdated
Per Copilot review on #140 — the previous "final assignment's value"
phrasing was imprecise. The evaluator actually reads global `_` (the
Starlark convention for the anonymous value) and falls back to global
`result` when `_` is None. Updated the README section to match the
implementation in engines/starlark/evaluator/evaluator.go:127-138.

https://claude.ai/code/session_01C61VEAmjxSnX5Xhbab8NvL
@sonarqubecloud
Copy link
Copy Markdown

@robbyt robbyt merged commit cdbe9ee into main May 20, 2026
3 checks passed
@robbyt robbyt deleted the claude/review-repo-improvements-NDaxm branch May 20, 2026 03:18
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.

3 participants