| Age | Commit message (Collapse) | Author |
|
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.
|
|
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.
|
|
- 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
|
|
- 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
|