Skip to content

Commit

Permalink
More on patterns overhaul (#1110)
Browse files Browse the repository at this point in the history
This PR includes many tiny changes over mathics.core.pattern and
mathics.builtin.patterns.

* following @cory 's ExpReduce, the match method now has a `pattern_context` parameter that collects all the parameters. The linter seems to be happier with this change.
* More annotations
* More docstrings
* More on avoiding the use of Python's built-in functions as identifiers.
* `Rule` and `RuleDelayed` now check if they receive two parameters. If they receive more or less parameters, show a warning message.

The work is not complete but is closer to being: it remains to remove `**kwargs` from the match calls, as well as some other adjustments.

---------

Co-authored-by: rocky <[email protected]>
Co-authored-by: R. Bernstein <[email protected]>
  • Loading branch information
3 people authored Oct 3, 2024
1 parent 6860e5c commit 9cc2331
Show file tree
Hide file tree
Showing 8 changed files with 633 additions and 529 deletions.
2 changes: 1 addition & 1 deletion mathics/builtin/list/constructing.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def eval(self, expr, patterns, f, evaluation: Evaluation):
def listener(e, tag):
result = False
for pattern, items in sown:
if pattern.does_match(tag, evaluation):
if pattern.does_match(tag, {"evaluation": evaluation}):
for item in items:
if item[0].sameQ(tag):
item[1].append(e)
Expand Down
Loading

0 comments on commit 9cc2331

Please sign in to comment.