Update Item Specifications

Glen Whitney 2025-04-02 03:08:02 +00:00
parent 2544a93669
commit 7d95c72f70

@ -75,10 +75,20 @@ Note here that ideally the accesses to `math.config.predictable` and `math.types
Looking at how other config properties might work, let's suppose that the `constants` property gives the numeric type that should be used for named constants (e.g., Number or BigNumber). We want `math.tau` to give a scalar entity, but we'd also like to record different possible entities for different types. Since we can't put properties on a number, we use a resolve function directly on the math object that takes the identifier to resolve:
```
export tau = [
export const tau = [
[Number], 6.2831853,
[BigNumber], math => math.bignumber('6.28318530717958647692'),
[], math => math.resolve('tau', [math.config.constants])
]
```
A few things to note in this example: now clients of the eventual bundle can use `math.resolve('tau', math.BigNumber)` to get the BigNumber value of tau regardless of the current type in the config.constants setting, the plain `math.tau` should resolve to the correct scalar entity, and the plain `math.tau` should be reset if either config.constants changes or if the setting of math.tau on the type config.constants changes.
A few things to note in this example: now clients of the eventual bundle can use `math.resolve('tau', math.BigNumber)` to get the BigNumber value of tau regardless of the current type in the config.constants setting, the plain `math.tau` should resolve to the correct scalar entity, and the plain `math.tau` should be reset if either config.constants changes or if the setting of math.tau on the type config.constants changes.
Finally, let's see how the troubling example of absquare in https://code.studioinfinity.org/glen/pocomath/issues/55 would pan out:
```
export const absquare = [[Complex], (math, [T]) => {
const absq = math.absq.resolve(T.Base)
const add = math.add.resolve(absq.returns, absq.returns)
return Returns(add.returns, z => add(absq(z.re), absq(z.im))
}
```
This seems like a success of this scheme to me. Hence, the current plan is to recast the prototype into this format.