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 augmented assignment operators to Macaulay2 language #3079

Merged
merged 22 commits into from
Jan 24, 2024

Commits on Jan 24, 2024

  1. Add augmented assignment operator symbols

    One for most flexible binary operators (omitting ones that would
    introduce ambiguity or give syntax errors) with the same precedence as
    = (to match C).
    d-torrance committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    43e5866 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    35838ab View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    434e92d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    589b030 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8d9c101 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    c65c0a9 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    48c9c1d View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    eee628f View commit details
    Browse the repository at this point in the history
  9. Identify augmented assignment methods as assignment methods

    This way it won't complain when we try to install a function with two
    arguments.
    d-torrance committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    ddd951c View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    802f741 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    36b087f View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    ae8d559 View commit details
    Browse the repository at this point in the history
  13. Add augmented assignment operators to operatorAttributes hash table

    They're binary and they're flexible, but they're a little different
    than the members of flexibleBinaryOperators.  In particular, we don't
    want to run installAssignmentMethod on them, which is why we keep them
    separate from flexibleBinaryOperators.
    d-torrance committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    1b0b74e View commit details
    Browse the repository at this point in the history
  14. Provide fallback for user-defined augmented assignment methods

    If the method returns the "Default" symbol, then fall back to the
    usual behavior.
    
    This is useful for example for the Python package, where we'd like +=
    to call the __iadd__ method, but only if it exists.
    d-torrance committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    870fc93 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    aff6ef2 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    de097cd View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    119da49 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    a6b76e1 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    849ad5a View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    5877b8b View commit details
    Browse the repository at this point in the history
  21. Add new evaluatedCode member of Code union

    This will be used by augmented assignment.  The problem was that we
    first want to check if a user-defined method for augmented assignment
    is installed, which requires evaluating the code on the left-hand side
    of the operator.  But if we *don't* use a user-defined method (which
    will be the case most of the time), then we want the original code,
    since that's what the binary operators expect.
    
    The solution is to create a member of the Code union that saves the
    evaluated code.  Then we can evaluate early on but still call the
    binary operators later if need.
    d-torrance committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    d7ef94c View commit details
    Browse the repository at this point in the history
  22. Refactor augmented assignment so we don't evaluate things twice

    Evaluate everything immediately but store it as evaluatedCode for
    later.
    d-torrance committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    7d8107a View commit details
    Browse the repository at this point in the history