Skip to content

Interactive scopes #51434

@simonbyrne

Description

@simonbyrne

Looking at how ScopedValues are used for the logger (#50958) and my proposed use for MPFR precision and rounding (#51362), we've ended up with a pattern where if the ScopedValue isn't defined, we fall back on a global Ref value which can be set globally, defining an accessor like:

something(Base.ScopedValues.get(SCOPED_VALUE), GLOBAL_REF[])

If this is going to be common, it seems like a clunky pattern. One straightforward solution would be to make the default field mutable (which would remove the need for this pattern), but it is perhaps worth considering why this is used.

@vchuravy asked if it was important if we be able to set the precision globally. I mentioned backward compatibility, but the primary rationale is for interactivity: if I want to increase the precision for all my last calculation, I can just call setprecision(BigFloat, 1024), and then re-evaluate the expression (hit up arrow twice, and return). If I didn't have this ability, I would have to wrap everything expression in setprecision(BigFloat, 1024) do .... end, which is fiddly and time consuming.

However, if we had some way to evaluate inside a given scope at the REPL, this might not be necessary: basically what I want is something similar to the contextual module REPL, but for scopes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    REPLJulia's REPL (Read Eval Print Loop)featureIndicates new feature / enhancement requestsmultithreadingBase.Threads and related functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions