summaryrefslogtreecommitdiff
path: root/internal/rpn/variable.go
AgeCommit message (Collapse)Author
2026-05-23refactor: remove dead hyper.go and variable.go filesPaul Buetow
Delete internal/rpn/hyper.go (HyperOperations, 351 lines) and internal/rpn/variable.go (VariableOperations, 76 lines). Both define duplicate operator structs that are never instantiated by any live code path. The authoritative metric-aware implementations live on the Operations struct in operations_hyper.go and operations_variables.go. YAGNI/DRY: removes 427 lines of dead code maintenance burden.
2026-05-22refactor(rpn): split StringNum/Symbol out of Number interface (LSP fix)Paul Buetow
StringNum and Symbol implemented Number but their Float64(), Compare(), Bool(), IsZero(), IsNegative(), and SetMetric() methods always returned errors. Any code accepting Number had to defensively check IsString()/IsSymbol() before arithmetic, defeating the interface. Split Number into two interfaces: - StackValue: base interface for anything on the stack (String, IsBool, IsString, IsSymbol, Metric) - NumericValue: embeds StackValue + arithmetic contract (Float64, IsZero, IsNegative, Compare, Bool, SetMetric) Float and Rat implement both; StringNum and Symbol implement StackValue only. Keep Number as a type alias for backward compat. Updated Stack, popStack/popTwo/popAll, toFloat64, resolveMetric, convertToBase, GetCurrentStack/SetCurrentStack, and all callers to use the correct interface level.
2026-04-11Refactor number.go to return errors instead of panickingPaul Buetow
- Changed Number interface methods to return errors instead of panicking - Float64() now returns (float64, error) - Add, Sub, Mul, Pow, Compare, Bool() now return (Number, error) or (int, error) - StringNum and Symbol now return errors for unsupported operations - Added IsString() and IsSymbol() to Number interface - Removed unused arithmetic.go file - Updated operations.go, boolean_ops.go, hyper.go to handle errors - Added constants registry (internal/rpn/constants.go) with built-in math constants - Added constants_test.go with comprehensive unit tests - Updated README.md with constants documentation
2026-03-25Fix Ln operation and add comprehensive testsPaul Buetow
- Fixed Ln operation to handle Value conversion before math.Log using Float64() which handles boolean conversion (true → 1, false → 0) - Added TestLnWithBoolean and TestLnEdgeCases tests for comprehensive coverage - Refactored operations.go into separate files (arithmetic.go, boolean_ops.go, hyper.go, stack.go, variable.go) - Removed unused toNumber function from number.go - Added Float64() method to Value struct for boolean conversion