-
Notifications
You must be signed in to change notification settings - Fork 35
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
Builtins Milestone 2: Final PR, No Conflict! #101
base: 2022
Are you sure you want to change the base?
Conversation
Signed-off-by: LER0ever <[email protected]>
Signed-off-by: LER0ever <[email protected]>
Signed-off-by: LER0ever <[email protected]>
Signed-off-by: LER0ever <[email protected]>
Rongyi/builtins import
Signed-off-by: LER0ever <[email protected]>
Signed-off-by: LER0ever <[email protected]>
39 Javascript math functions were registered to builtin functions, but only 3 of them have unit tests, 20-ish of them use Float arguments, which we currently do NOT support. Will add some additional unit test on them and manually add back those that passes the tests. Revert "Merge remote-tracking branch 'origin/expanded-math' into milestone2" This reverts commit 6a876c3, reversing changes made to ffddc3c.
a few unit tests + functionality
Signed-off-by: LER0ever <[email protected]>
Update since we filed the PRNOTICE on reversion of commit: 6a876c3 "a few unit tests + functionality"6a876c3 (and thus a039ed7) was reverted because most JS math functions registered in that commit is not working and not unit-tested. 39 Javascript math functions were registered to builtin functions, but only 3 of them have unit tests, 20-ish of them use Float arguments, which we currently do NOT support. Several bigint functions have no usecases, such as UPDATE: Part of that commit was added back in 89c07b7 , which includes Support Float Type in Function parameters and returnsThe fix from 7d023f2 and 8551df3 enabled us to use floating point in functions. Therefore we added back a |
Signed-off-by: LER0ever <[email protected]>
Signed-off-by: LER0ever <[email protected]>
Signed-off-by: LER0ever <[email protected]>
Built-in Libraries, Import Statements, Float, Print
This PR supersedes all of our previously unmerged PRs: #10 , #46 , #77 . We've consolidated all our previous changes (from both milestone 1 and 2) to this single pull request, which currently has no merge conflict with
2022
branch and passes all the unit tests!The previous 3 PRs are therefore now deprecated, please merge this one instead. It's ready to land in 2022!
Float Type
Import Statement
We implemented a simple import statement to control which builtin functions are enabled.
Builtin Library
See all the builtin function database here at builtins.ts
Builtin Functions
These functions are available globally, works with bigint, and do not require import to use
Math Library
These functions requires import to use, and works with bigint. For example:
Float Math Library
We separate the math lib into bigint and float, since we cannot access generics and these two types have different loading mechanisms.
Random Library
The following code for example generates a random number between factorial 20! and 40!, both are really huge.
Other library
Adding new modules and functions are fairly easy, just implement the function in TypeScript and bridge them to ChocoPy by adding them to the builtin function database.
We originally planned to implement more interesting builtin libraries such as
path
,re
,time
, etc. But those heavy rely on the implementation from the Strings & IO group, neither of which are merged unfortunately.