Introduce BooleanT and boolean functions #17

Merged
glen merged 7 commits from booleans into main 2025-04-13 16:29:53 +00:00
Owner

This PR adds a boolean section, as well as an isNaN predicate on numbers. In a TypeDispatcher, when BooleanT is present, isNaN returns a BooleanT. However, in a numbers-only TypeDispatcher, it returns 1 or 0 instead. Moreover, when booleans are subsequently added to a numbers-only instance, isNaN properly reconfigures itself to return BooleanT.

No predicates that depend on approximate equality testing or a configuration object are implemented in this PR.

This PR also implements type matching and dispatching with implicit conversions, and adds an implicit conversion from BooleanT to NumberT.

This PR adds a boolean section, as well as an isNaN predicate on numbers. In a TypeDispatcher, when BooleanT is present, isNaN returns a BooleanT. However, in a numbers-only TypeDispatcher, it returns 1 or 0 instead. Moreover, when booleans are subsequently added to a numbers-only instance, isNaN properly reconfigures itself to return BooleanT. No predicates that depend on approximate equality testing or a configuration object are implemented in this PR. This PR also implements type matching and dispatching with implicit conversions, and adds an implicit conversion from BooleanT to NumberT.
glen added 1 commit 2025-04-10 21:06:37 +00:00
refactor: prepare for boolean functions
All checks were successful
/ test (pull_request) Successful in 19s
5bee93dbb3
* Defines a BooleanT type
  * adds options to the Type constructor, so far just to allow conversions
    from other types
  * renames Number type to NumberT
  * records the name of types, and puts the name in the string representation
  * defines a conversion fron BooleanT to NumberT, specified to be automatic
  * stub code for automatic conversions, not yet complete
  * BooleanT not yet added to nanomath

Checked that the new facilities do not disrupt the prior behavior on numbers.
glen added 1 commit 2025-04-11 05:52:27 +00:00
feat: implicit convert BooleanT to NumberT
All checks were successful
/ test (pull_request) Successful in 19s
bfc64f3789
Also adds implicit conversion configuration option to Type constructor,
  and institutes a numbers-only bundle, and supports argument matching
  with implicit conversions.

  Still need to test that a behavior that invokes implicit conversion ends up
  with the conversion operation as a dependency (and so regenerates itself if
  the conversion changes).
glen added 1 commit 2025-04-12 07:13:28 +00:00
test: ensure that a function requiring conversion depends on converter
All checks were successful
/ test (pull_request) Successful in 17s
f38a2d5e88
This test turned out to be a very discerning one. Adding it uncovered
  numerous bugs, large and small, in the TypeDispatcher. The most major
  one was that a Map distinguishes keys by strict equality, and hence
  since every lookup for a cached behavior was using a newly-generated array
  of types, the cache was never being hit. So it looked like methods were
  being updated as dependencies changed, when what was really happening
  was that the behavior was simply being regenerated from scratch on every
  call, which would not be performant as the prototype scaled.
  This bug is now fixed (by switching to a third-party ArrayKeyedMap), along
  with many smaller bugs too numerous to list.

  It should now be feasible to go through Pocomath and add all of the functions
  that depend on numbers and booleans only.
glen added 1 commit 2025-04-12 14:46:30 +00:00
feat: add conversions to boolean and make mandatory
Some checks failed
/ test (pull_request) Failing after 16s
4b81fbe6e2
glen added 1 commit 2025-04-13 07:15:13 +00:00
chore: add boolean test files omitted earlier
All checks were successful
/ test (pull_request) Successful in 18s
a7673216c1
glen added 1 commit 2025-04-13 08:37:38 +00:00
feat: factories can depend on the presence of types
All checks were successful
/ test (pull_request) Successful in 17s
b2b41d6348
Refactors each TypeDispatcher to have its own separate collection
  of types. Add isnan function which returns a boolean if that type
  is present, otherwise returns the number 1 for true, and 0 for fase.
glen added 1 commit 2025-04-13 09:00:52 +00:00
fix: clear behaviors that depend on an object property
All checks were successful
/ test (pull_request) Successful in 17s
447c62eae9
glen changed title from WIP: Introduce BooleanT and boolean functions to Introduce BooleanT and boolean functions 2025-04-13 16:22:36 +00:00
glen merged commit 27fa4b0193 into main 2025-04-13 16:29:53 +00:00
glen deleted branch booleans 2025-04-13 16:29:53 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: StudioInfinity/nanomath#17
No description provided.