Skip to content

PikachuHy's Scheme support Continuation now

Latest

Choose a tag to compare

@PikachuHy PikachuHy released this 14 Dec 13:22
· 27 commits to master since this release
logo_white

Release Date: 20251214

We are pleased to announce the release of pscm v0.5.0.

This is a significant milestone release. Almost all of the code was written with AI assistance in Cursor after commit 8380f9c , demonstrating the power of AI-assisted development in building complex language implementations.

This version implements complete Scheme core functionality with approximately 11,000+ lines of code. Designed with reference to Guile 1.8, it provides continuation support based on setjmp/longjmp, enabling advanced control flow patterns that are essential for Scheme programming.

πŸŽ‰ What's New

Complete Scheme Core Implementation

  • Full type system with 17 data types
  • Comprehensive parser and evaluator
  • Continuation support via setjmp/longjmp
  • Rich built-in function library
  • Enhanced error handling with stack traces

Key Features

  • Type System: Unified SCM type supporting 17 data types including NIL, LIST, NUM, FLOAT, RATIO, CHAR, STR, SYM, BOOL, PROC, FUNC, CONT, MACRO, HASH_TABLE, VECTOR, PORT
  • Continuation Support: First-class continuations implemented using setjmp/longjmp with dynamic-wind support
  • Parser: Hand-written recursive descent parser with full Scheme syntax support
  • Evaluator: Tail-recursive optimized evaluator with modular special form handling
  • Error Handling: Enhanced error reporting with source location tracking and call stack traces (up to 20 levels)

πŸ“¦ Core Functionality

Data Structures

  • Lists with dotted pair support
  • Lexical scoping with environment chains
  • Hash tables with three equality modes (eq?, eqv?, equal?)
  • Fixed-length vectors with random access

Built-in Functions

Comprehensive library including:

  • Type predicates: procedure?, boolean?, null?, pair?, char?, number?
  • List operations: car, cdr, cons, list, append, set-car!, set-cdr!
  • Numeric operations: +, -, *, /, expt, abs (with mixed integer/float/ratio support)
  • String and character operations
  • Vector operations
  • Hash table operations
  • Port operations (file and string ports)
  • System operations: exit

Special Forms

define, lambda, if, cond, case, and, or, begin, let/let*/letrec, do, for-each, map, quote, quasiquote, apply, call/cc, call-with-values, dynamic-wind

C/C++ Integration

Guile 1.8-compatible function registration:

  • Fixed parameters: scm_define_function
  • Generic functions: scm_define_generic_function
  • Variadic functions: scm_define_vararg_function

⚠️ Known Limitations

  1. Memory Management: No garbage collection (GC) implemented yet. All allocated memory is not freed, which may cause memory leaks.
  2. Error Handling: Most errors result in exit(1), lacking graceful error recovery mechanisms (though call stack tracing is available).
  3. Performance: Environment lookup uses linear search (O(n)), and symbol comparison uses memcmp.
  4. Missing Features: Module system, file loading functions (load), Guile API compatibility layer.

πŸš€ What's Next

High Priority

  • Implement garbage collection mechanism
  • File loading functions (load, primitive-load)
  • Guile API compatibility layer (C API interface)

Medium Priority

  • Module system (code organization)
  • Enhanced error handling (exception catching, currently has call stack tracing)
  • More Scheme standard features (delay/force, etc.)

πŸ“š Documentation

πŸ™ Acknowledgments

Special thanks to all contributors and the AI-assisted development tools that made this release possible!


Note: pscm is still in an early stage. Please use with caution in production environments.