summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-24 12:52:20 +0300
committerPaul Buetow <paul@buetow.org>2026-05-24 12:52:20 +0300
commite01d707cc31cff61f796cb6afb3e9c1275891fda (patch)
treedbcb794e40f31ba31140b2643c94529e6d7f6444 /internal
parenta5ed0193f6b100933df1d4f89b693141ce59549e (diff)
rpn: remove exported Number type alias
type Number = NumericValue was a legacy alias that created confusion — callers could use Number or NumericValue interchangeably. Removed the alias and updated: - NewNumber/NewNumberWithMetric return types: Number -> NumericValue - Comments referencing Number now say NumericValue The alias added no value since Number was never used as a distinct type anywhere in the codebase.
Diffstat (limited to 'internal')
-rw-r--r--internal/rpn/number.go15
-rw-r--r--internal/rpn/operations_constants.go2
-rw-r--r--internal/rpn/operations_variables.go2
-rw-r--r--internal/rpn/variables.go2
4 files changed, 12 insertions, 9 deletions
diff --git a/internal/rpn/number.go b/internal/rpn/number.go
index a188edf..de6fa93 100644
--- a/internal/rpn/number.go
+++ b/internal/rpn/number.go
@@ -44,8 +44,11 @@ type NumericValue interface {
SetMetric(m *Metric) NumericValue
}
-// Number is the legacy alias for NumericValue, kept for backward compatibility.
-type Number = NumericValue
+// NumericValue is the interface for numeric values (float64 or *big.Rat).
+// It extends StackValue with metric operations.
+//
+// Note: type Number was a legacy alias for NumericValue, removed to avoid
+// confusion between the alias and the concrete type.
// Compile-time interface satisfaction checks.
var _ StackValue = (*Float)(nil)
@@ -55,20 +58,20 @@ var _ NumericValue = (*Rat)(nil)
var _ StackValue = (*StringNum)(nil)
var _ StackValue = (*Symbol)(nil)
-// NewNumber creates a Number from a float64 value with the given mode.
+// NewNumber creates a NumericValue from a float64 value with the given mode.
// The actual type depends on the current calculation mode (Float or Rat).
// The metric defaults to Cool (unitless).
-func NewNumber(value float64, mode CalculationMode) Number {
+func NewNumber(value float64, mode CalculationMode) NumericValue {
if mode == RationalMode {
return NewRat(value)
}
return NewFloat(value)
}
-// NewNumberWithMetric creates a Number from a float64 value with an explicit metric.
+// NewNumberWithMetric creates a NumericValue from a float64 value with an explicit metric.
// The actual type depends on the current calculation mode (Float or Rat).
// If metric is nil, defaults to Cool.
-func NewNumberWithMetric(value float64, mode CalculationMode, metric *Metric) Number {
+func NewNumberWithMetric(value float64, mode CalculationMode, metric *Metric) NumericValue {
if metric == nil {
metric = GetCoolMetric()
}
diff --git a/internal/rpn/operations_constants.go b/internal/rpn/operations_constants.go
index 7fbd4c9..8cb0366 100644
--- a/internal/rpn/operations_constants.go
+++ b/internal/rpn/operations_constants.go
@@ -19,7 +19,7 @@ func (o *Operations) ListConstants() (string, error) {
}
sb.WriteString(info.Name)
sb.WriteString(" = ")
- // Use Number interface for consistent formatting
+ // Use NumericValue interface for consistent formatting
num := NewNumber(info.Value, FloatMode)
sb.WriteString(num.String())
}
diff --git a/internal/rpn/operations_variables.go b/internal/rpn/operations_variables.go
index fb340ec..49cab57 100644
--- a/internal/rpn/operations_variables.go
+++ b/internal/rpn/operations_variables.go
@@ -25,7 +25,7 @@ func (o *Operations) AssignVariable(stack *Stack, name string) error {
return err
}
- // Convert Number to float64 for variable storage
+ // Convert NumericValue to float64 for variable storage
valF, err := toFloat64(val, "assigning variable")
if err != nil {
return err
diff --git a/internal/rpn/variables.go b/internal/rpn/variables.go
index 56eb1ae..ac04cf1 100644
--- a/internal/rpn/variables.go
+++ b/internal/rpn/variables.go
@@ -185,7 +185,7 @@ func (v *Variables) formatVariablesUnsafe() string {
if i > 0 {
sb.WriteString("\n")
}
- // Use Number interface for consistent formatting
+ // Use NumericValue interface for consistent formatting
num := NewNumber(info.Value, FloatMode)
sb.WriteString(info.Name)
sb.WriteString(" = ")