WIP - function overloading #8280
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a WIP progress, the basic shape is there, but there are some issues to resolve. Essentially a function value in memory gets a Vec of function definitions rather than a single one.
The motivation is to have a nice way to handle functions like
line
andarc
for both sketch mode 1 and 2. In theory, which you get could depend on the sketch if that was the first argument, but in practice an even easier overloading is that we distinguish between there being an input argument and there not being one (sketch mode 1 has one, v2 does not).The complications are: handling multiple function definitions in our docs and for IDE stuff like hover and autocomplete, also since we're doing mutation of the value in memory, we need to interact with the epoch systems of program memory and check that function is defined at the point of call. These are both definitely solvable, but make this solution harder than otherwise.
I think, on balance, it is probably not worth finishing this work and a more ad-hoc versioning thing might be easier (e.g., special-casing the sketch2 module inside sketch blocks). But I'm sharing this branch in case y'all decide this is the best approach.