-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New vs Create, and other API cleanups, and Instantiating Numbers #58
Comments
For the |
+1 @cbelsole thanks! |
Some updates:
|
Looking at this a few months later, not a fan of Some inspirations
|
We're going to go with |
Renames
NewValue
and replace it instead by aNewNumber
of some sort -- see below. Right now, because we haveNewUndefined
,NewText
, andNewBool
, the generic helperNewValue
is used only to create numbers;NewDefinitions
toParseDefinitions
to more clearly indicate what's involved;NewWorksheet
toCreateWorksheet
to differentiate it from creating new values: worksheets can be mutated and have a lifecycle, whereas undefined/text/bool/number are immutable values.NewStore
toNewDbStore
because it creates a*DbStore
. (We could imagine having aFileStore
at some point, or similar.)Instantiating Numbers
Provide two constructors which are guaranteed not to panic, plus the constructor from string:
func NewNumberFromInt(int64) *Number
func NewNumberFromFloat(float64) *Number
func NewNumberFromString(string) (*Number, error)
Here is a quick survey of the Golang world of arbitrary-precision math libraries which informed the suggestion above:
func New(coeff int64, exponent int32) *Decimal
func NewFromString(s string) (*Decimal, Condition, error)
func NewWithBigInt(coeff *big.Int, exponent int32) *Decimal
func NewFloat(x float64) *Float
func NewInt(x int64) *Int
func NewRat(a, b int64) *Rat
func New(value int64, exp int32) Decimal
func NewFromBigInt(value *big.Int, exp int32) Decimal
func NewFromFloat(value float64) Decimal
func NewFromFloatWithExponent(value float64, exp int32) Decimal
func NewFromString(value string) (Decimal, error)
The text was updated successfully, but these errors were encountered: