Skip to content

Make standard syntax for Refresh with 1 argument #497

@JerryI

Description

@JerryI

Current implementation of Refresh does not follows the official documentation of Wolfram Standard Library.

Refresh[Now]

will results in just Now. To make it work we added extra argument:

Refresh[Now, 1]

this will work and reevaluate Now every second.

Problem

By the default, outside Mathematica the internal variable $FrontEnd is Null, which automatically resolve all Refresh[expr] to expr.

However all DownValues, UpValues of Refresh are empty (FormatValues do not count, Identity resolution happens even for InputForm). This means, Refresh is not constructed using default Wolfram Language syntax (or hidden on purpose).

Ok. Another way is to simply (that should not change anything normally if DownValues are empty)

Unprotect[Refresh];
ClearAll[Refresh];

Refresh /: MakeBoxes[Refresh[expr_], StandardForm] := "Hi there!";

This will nicely work. But what a surprise - now it breaks NeuralNet* package!

Our workaround

Then we do not clean all values, but only FormatValues:

Unprotect[Refresh];
FormatValues[Refresh] = {};

Refresh /: MakeBoxes[Refresh[expr_], StandardForm] := "Hi there!";

this will not work As we know, there is DownValues, that sets Refresh basically to Identity operator.

Since WLJS 2.5.0 and till now we still do it in a different way without affecting other internal packages:

Unprotect[Refresh];
FormatValues[Refresh] = {};

Refresh /: MakeBoxes[Refresh[expr_, period_?NumberQ], StandardForm] := ...our implementation;

Then this works now

Refresh[Now, 1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions