Skip to content

refactor!: remove pure-function API, engine is RPN-only#15

Merged
shanehull merged 1 commit into
mainfrom
feat/rpn-only
Jul 23, 2026
Merged

refactor!: remove pure-function API, engine is RPN-only#15
shanehull merged 1 commit into
mainfrom
feat/rpn-only

Conversation

@shanehull

@shanehull shanehull commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Breaking Change

The engine package no longer exports pure functions. All math is now package-private and accessed through the Engine struct's RPN methods. SetN/SetI/SetPV/SetPMT/SetFV now take a value argument.

Removed exports

  • Pure functions: FV, PV, PMT, NPer, Rate, SolveTVM, NPV, IRR, DepSL, DepSOYD, DepDB, Amort, BondPrice, BondYield
  • Types/constants: Timing, End, Begin, MaxDigits, NaNf64
  • Errors: ErrNoConvergence, ErrNoSolution

Migration

Before:

pmt := engine.PMT(0.06/12, 360, 300000, 0, engine.End)
e.X = 5; e.SetI()

After:

e := engine.New()
e.SetN(360)
e.SetI(0.5)
e.SetPV(300000)
e.SolvePMT()

Changes

  • Unexport all math functions; Engine methods delegate internally
  • Parameterize SetN/SetI/SetPV/SetPMT/SetFV with value arguments
  • Rename finance.go to math.go for clarity
  • Delete finance_example_test.go (pure-function examples)
  • Convert examples/ to Engine RPN usage
  • Remove Functional API section from README

BREAKING CHANGE: The engine package no longer exports pure functions.
All math (FV, PV, PMT, NPV, IRR, DepSL, DepSOYD, DepDB, Amort,
BondPrice, BondYield, SolveTVM, Rate, NPer, Timing, End, Begin,
NaNf64, ErrNoConvergence, ErrNoSolution, MaxDigits) is now
package-private. SetN/SetI/SetPV/SetPMT/SetFV now take a value
argument instead of reading from the X register.

Migration:
  e.X = 360; e.SetN()  →  e.SetN(360)
  e.X = 5; e.SetI()    →  e.SetI(5)

- Unexport all math functions; Engine methods delegate internally
- Parameterize SetN/SetI/SetPV/SetPMT/SetFV with value arguments
- Rename finance.go -> math.go for clarity
- Delete finance_example_test.go (pure-function examples)
- Convert examples/ to Engine RPN usage
- Remove Functional API section from README
@shanehull
shanehull merged commit b21acba into main Jul 23, 2026
6 checks passed
@shanehull
shanehull deleted the feat/rpn-only branch July 23, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant