Repository navigation
Type hinting via comments, relaxed math compiler setting/flag, no casting flag - #355
derpygamer2142 wants to merge 6 commits into
Conversation
Adds type hinting for variables, lists and custom block arguments via comments, and settings to disable casting and to make the compiler less likely to determine a math operation is NaN.
712903e to
4a8e880
Compare
|
this should be 3 separate PRs and needs to be discussed a lot more we know there are still ways to improve performance for everyone for free in the compiler. we can add types to procedure arguments if we tried, for example, so letting people put weird magic comments that can break behavior wouldn't really make sense until we've actually exhausted that |
|
i can split this into different prs if you want, and i wouldn't really be disappointed about removing the nocast flag because it's pretty esoteric. |
Proposed Changes
Adds a system for hinting variable, list, and procedure argument types to the compiler. Also adds two settings, relaxedmath and nocast, which make the compiler less likely to determine that an operation will be NaN/Infinity, and severely limit casting, respectively. The compiler settings have a corresponding gui pr which lets you enable relaxedmath across the entire project: TurboWarp/scratch-gui#1196
Also has a corresponding docs pr because the format for hinting is weird: TurboWarp/docs#135
Reason for Changes
We can't really get around the conservative guesses that the compiler makes for perfect Scratch compatibility, relaxed math tries to account for some of that. Type hinting is to keep people from driving themselves to madness by trying to coerce the compiler into not generating toNotNaN() calls, and because there's no type inference for lists. nocast is just for the crazy people and breaks most projects I tested when enabled globally, but someone might find it interesting.
Test Coverage
Updated the usages of IROptimizer in the test suites to account for the change to the constructor