Skip to content

feat: implement EXIT word #24

@tetsuo-cpp

Description

@tetsuo-cpp

Summary

Implement the EXIT standard Forth word for early return from a word (user-defined function).

Motivation

Common in utility words with multiple exit conditions. Without EXIT, the only way to return early is to restructure the entire word with nested IF/ELSE/THEN, which is verbose and harder to read.

Implementation notes

  • EXIT should emit func.return with the current stack value at the point it appears in the word body, rather than only at the end.
  • The translator must ensure the stack state is valid at the EXIT point.

Related

Tracked as a high-impact gap in #16.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions