This document provides guidelines for AI assistants working on the rtcl project.
rtcl is a lightweight, no-std compatible Tcl interpreter implemented in Rust.
- Minimal implementation focused on embedded systems
- Tcl-compatible syntax and commands
- No external dependencies for core functionality
- Expect-style process automation support
- Keep code simple and focused
- Avoid over-engineering
- Prefer standard library over external dependencies
- Use clear, descriptive names
- Document complex logic with comments
- Use
clippyrecommendations - Follow standard Rust formatting (
cargo fmt) - Prefer
Result<T, E>for error handling - Use
#[cfg(feature)]for conditional compilation - Document public APIs with doc comments
- Prefer stack allocation over heap allocation
- Use
SmallVecfor small collections - Avoid unnecessary clones
- Consider
Cowtypes for shared data
rtcl-core: Core interpreter (no-std compatible)rtcl-cli: Command-line interfacertcl-expect: Process automation
Value: Tcl value (essentially a string)Interp: Interpreter stateParser: Source code parserError: Error types
Commands are implemented as static methods on Interp:
fn cmd_xxx(interp: &mut Interp, args: &[Value]) -> Result<Value>- Unit tests in each crate's
src/directory - Integration tests using
.tclfiles - Run tests:
cargo test - Check coverage:
cargo tarpaulin
- Check existing code patterns first
- Maintain compatibility where possible
- Add tests for new functionality
- Update documentation for API changes
- Run
cargo clippybefore committing
- Add method to
Interpimplementation - Register in
register_builtins() - Add tests
- Update help text in CLI
- Add to
types/expr.rs - Handle in
eval_expr() - Add tests for edge cases
- Profile before optimizing
- Measure impact with benchmarks
- Consider no-std targets
- Tcl documentation: https://www.tcl.tk/man/
- Jim Tcl (minimal implementation): G:/src.tcl/jimtcl
- Molt (Rust Tcl): G:/src.tcl/molt