Add Result type for consistent error propagation #59

Open
opened 2026-02-07 17:11:02 +00:00 by navicore · 0 comments
navicore commented 2026-02-07 17:11:02 +00:00 (Migrated from github.com)

Summary

Adopt a consistent Result type (Ok/Err) for error propagation throughout the evaluator, inspired by the seq-lisp-2 experiment.

Motivation

Currently seq-lisp uses a mix of approaches for error handling:

  • #f returns
  • String error messages
  • Crashes/panics

seq-lisp-2 demonstrated a clean Result union type (Ok/Err) threaded through the entire evaluator, making error propagation explicit and consistent. Every operation that can fail returns a Result.

Scope

  • Define Result union type in src/types.seq or equivalent
  • Thread Result through evaluator dispatch in src/eval.seq
  • Update all builtin operations to return Result
  • Ensure try/catch mechanism works with the new type
  • Maintain backward compatibility with existing Lisp-level error handling

Notes

This is the most invasive change of the seq-lisp-2 back-ports — it touches nearly every function in the Seq-level evaluator. Should be planned carefully and possibly done incrementally.

Inspired by seq-lisp-2/src/types.seq and seq-lisp-2/src/eval.seq.

## Summary Adopt a consistent `Result` type (`Ok`/`Err`) for error propagation throughout the evaluator, inspired by the seq-lisp-2 experiment. ## Motivation Currently seq-lisp uses a mix of approaches for error handling: - `#f` returns - String error messages - Crashes/panics seq-lisp-2 demonstrated a clean `Result` union type (`Ok`/`Err`) threaded through the entire evaluator, making error propagation explicit and consistent. Every operation that can fail returns a `Result`. ## Scope - Define `Result` union type in `src/types.seq` or equivalent - Thread `Result` through evaluator dispatch in `src/eval.seq` - Update all builtin operations to return `Result` - Ensure `try`/catch mechanism works with the new type - Maintain backward compatibility with existing Lisp-level error handling ## Notes This is the most invasive change of the seq-lisp-2 back-ports — it touches nearly every function in the Seq-level evaluator. Should be planned carefully and possibly done incrementally. Inspired by `seq-lisp-2/src/types.seq` and `seq-lisp-2/src/eval.seq`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
navicore/seq-lisp#59
No description provided.