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.

Home Page:https://mathics.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Exit` builtin not working

adamantinum opened this issue · comments

Exit builtin doesn't seem to work. The rule for Quit in mathics/builtin/evaluation.py seems correct to me, but Exit does nothing and doesn't show up among the available builtins in mathicsscript's autocompletion. Quit works just fine.
If there is anything else I could check, I would be glad to do it.

I guess that the problem is in how we load rules from builtin objects: since the pattern in the rule does not have Quit as a head, it assumes that the rule is an Upvalue, but there is no Builtin associated with the head, so at the end, the rule is not loaded.

The problem is that the loading mechanism is not showing an error when this happens.

#998 provides a patch to provide the Exit symbol, but at some point, we need to fix the Builtin.contribute mechanism.

I guess that the problem is in how we load rules from builtin objects: since the pattern in the rule does not have Quit as a head, it assumes that the rule is an Upvalue,

Are saying that this the wrong thing to do? If so, what would the right thing to do be?

I tried using a Delayed assignment and that works.

In[1]:= Exit2[n___] := Quit[n]
Out[1]= None

In[2]:= Exit2[]

Goodbye!

but there is no Builtin associated with the head, so at the end, the rule is not loaded.

The problem is that the loading mechanism is not showing an error when this happens.

I think you mean that this is another problem, that this fails silently. The first problem of course being that

    rules = {
        "Exit[n___]": "Quit[n]",
    }

doesn't work and is expected to do so.

#998 provides a patch to provide the Exit symbol, but at some point, we need to fix the Builtin.contribute mechanism.

Please add a new issue for this so it doesn't get lost. Thanks.

In my opinion, #998 would be the right way to implement Exit as a Builtin. As an alternative, we could add a WL definition in the autoload folder. This in principle is a different problem than the one I state in #1000, but #996 is the reason why I realized this is something to fix.

In my opinion, #998 would be the right way to implement Exit as a Builtin.

Ok. Is there a way to observer a difference between the two kinds of implementation in WMA? If so, which way does WMA do it?

This in principle is a different problem than the one I state in #1000, but #996 is the reason why I realized this is something to fix.

Ok.