Skip to content
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

Add handler for typed function signature mismatch #125

Merged
merged 2 commits into from
Mar 11, 2022

Conversation

gwhitney
Copy link
Collaborator

This way a client can implement custom behavior in the situation that a typed function call does not match any of its signatures. One specific application is to enable symbolic computation in mathjs (see demo PR to come momentarily).

This is not currently recommended for merging, although if the feature is of interest it's close: it would just need documentation, tests, and likely it would be good to expose createError as well for potential use in a client's onMismatch handler.

@gwhitney gwhitney marked this pull request as draft March 10, 2022 00:12
gwhitney added a commit to josdejong/mathjs that referenced this pull request Mar 10, 2022
  This PR is not intended for merging as-is, but serves as an
  alternate demonstration (vis-a-vis issue #2437) that essentially all
  the ingredients already exist in mathjs for evaluation in which all
  undefined variables evaluate to symbols, therefore possibly returning
  an expression (Node) rather than a concrete value (while still
  evaluating all the way to concrete values when possible).
  Moreover, mathematical manipulation of symbolic expressions can be
  supported without circularity and without modifying numerous source
  files.

  This PR does however depend on a small addition to typed-function.js,
  see josdejong/typed-function#125.

  See (or run) examples/symbolic_evaluation.mjs for further details on this.
gwhitney added a commit to josdejong/mathjs that referenced this pull request Mar 10, 2022
  This PR is not intended for merging as-is, but serves as an
  alternate demonstration (vis-a-vis issue #2437) that essentially all
  the ingredients already exist in mathjs for evaluation in which all
  undefined variables evaluate to symbols, therefore possibly returning
  an expression (Node) rather than a concrete value (while still
  evaluating all the way to concrete values when possible).
  Moreover, mathematical manipulation of symbolic expressions can be
  supported without circularity and without modifying numerous source
  files.

  This PR does however depend on a small addition to typed-function.js,
  see josdejong/typed-function#125.

  See (or run) examples/symbolic_evaluation.mjs for further details on this.
@josdejong
Copy link
Owner

O wow, such a handler makes a lot of sense! Even if we would not use it in mathjs on short term, it is a useful addition.

Can you work out this PR please? (add tests+docs)

  Adds documentation and tests. Exposes the default mismatch handler
  so that a client can restore the default behavior, and exposes
  the createError method so that a custom handler can generate the
  standard message when it might want to.
@gwhitney gwhitney changed the title WIP: add handler for typed function signature mismatch Add handler for typed function signature mismatch Mar 10, 2022
@gwhitney gwhitney marked this pull request as ready for review March 10, 2022 22:06
@josdejong
Copy link
Owner

Thanks for writing docs and tests Glen, looks very neat 👌

@josdejong josdejong merged commit ad9c714 into josdejong:develop Mar 11, 2022
@josdejong
Copy link
Owner

Published now in v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants