Skip to content

Add printnow builtin for eager output#3

Open
patx wants to merge 1 commit intomainfrom
codex/fix-infinite-loop-in-while-statement
Open

Add printnow builtin for eager output#3
patx wants to merge 1 commit intomainfrom
codex/fix-infinite-loop-in-while-statement

Conversation

@patx
Copy link
Owner

@patx patx commented Feb 9, 2026

Motivation

  • Provide a way to eagerly evaluate arguments and print immediately instead of returning a Deferred for print when arguments contain Thunk/Deferred/Task values.
  • Make it easy to force immediate output in the async/no-await model used by the evaluator.

Description

  • Recognize printnow calls in the evaluator by adding is_printnow_ident in Expr::Call and resolve its arguments with resolve_if_needed instead of resolve_deferred_only when building the call argument list.
  • Add a new stdlib builtin printnow in install_stdlib that eagerly resolves Thunk, Deferred, and Task argument values and prints their repr() immediately, returning None.
  • Update the evaluator argument-handling logic so spawn still receives raw/unresolved values, print keeps its deferred behavior, and printnow forces eager resolution.
  • Document printnow(...) usage in README.md alongside the async expression statement behavior.

Testing

  • No automated tests were run for this change.

Codex Task

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.

1 participant