diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-25 17:25:00 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-25 17:25:00 +0200 |
| commit | 6b5bee78c239b221188eea2bebe0e87714970866 (patch) | |
| tree | c35622e61aa629c0912621b21655fdb8c04cfa1c /.github/workflows | |
| parent | f692d72dc840be8eb17857b2ef85ee42dde5fd3f (diff) | |
refactor: Refactor RPN to use Number interface uniformly for stack values
This commit refactors the internal/rpn package to use the Number interface
instead of the old Value struct for stack values. Key changes:
1. Updated Number interface to include IsBool() and Bool() methods for
boolean value support
2. Modified Float and Rat types to support boolean mode with:
- isBool and boolVal fields
- Float64() returns 1 for true, 0 for false
- String() returns 'true' or 'false' for boolean values
3. Updated Stack to use []Number instead of []Value
4. Updated all operations to use the Number interface methods directly
- Add, Sub, Mul, Div, Pow, Mod now use Float64() for values
5. Updated tests to use NewNumber() with mode parameter instead of
NewNumberValue(), and use Float64() instead of Number()
Benefits:
- Simplified code - no need for toNumber() and NewNumberValue() wrappers
- Better type safety - stack values are Number interface instances
- Boolean-to-number coercion works correctly in all operations
Diffstat (limited to '.github/workflows')
0 files changed, 0 insertions, 0 deletions
