Mathics3 / mathics-core

An open-source Mathematica. This repository contains the Python modules for WL Built-in functions, variables, core primitives, e.g. Symbol, a parser to create Expressions, and an evaluator to execute them.
https://mathics.org
Other
733 stars 42 forks source link

load builtins do not shows a warning when a rule fails to load #1000

Open mmatera opened 4 months ago

mmatera commented 4 months ago

996 puts the manifest the need to check if the rules included in the rule attribute of Builtin symbols are loaded or not. This happens for example when a rule in one Builtin symbol tries to define another symbol. In that case, the symbol Quit includes a rule to define the alias Exit with the rule Exit[n___]->Quit[n]. The problem is that this rule does not define a DownValue / Upvalue/ Subvalue; in the end, it is never added as a definition in the Definitions object.

I do not have a clear idea of the best way to handle this kind of case: One thing would be to create the Definition for the symbol (if it was not already loaded) and then add the rule. This has certain complexities and drawbacks: for example, if there is a Builtin, should the rule have higher priority than the rules in the Builtin?

The other way (much simpler) would be to just to add a warning when the rule cannot be associated to a *Value of the Builtin we are processing.