-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load user-customisations lazily #79
Conversation
I'm not sure it's worth doing this way; all users needing to call this manually seems like a much worse API and of course carries the risk that they will call it from their init method 😄 As an alternative, we're ok as long as it's easy to avoid loading this package, i.e. Base and most stdlibs don't depend on it. |
The reason why I'm proposing this is because I think (perhaps I'm mistaken) the vast majority of users won't need to call this method manually. Most interactive/rich output comes up in the REPL, and if just the REPL calls User scripts and certain statically-compiled files are the two cases that come to mind where a user might want to call it manually, but maybe that's a worthwhile tradeoff? |
dcd98d1
to
6c7a8ba
Compare
OK, that's good news. I'm ok with this then. |
This is primarily motivated by reducing the amount of work that trimming is unable to remove.
Let's give this a shot then 🙂 |
Ok, but then when you all of a sudden run something outside the REPL things will no longer work? So you might have code that works as you expect because you have a transitive dependency on the REPL but when that dependency is dropped by some of your own dependencies all of a sudden you lose all customisation. |
Yea, different visuals when running things in vs. out of the REPL is the potential downside (and I wonder if maybe this could be a good spot to use |
I think this is not a good way to do this and should be reverted. If something like this is to be done it should be done actually lazily by having the library itself initialize the customizations the first time it uses something that needs it. Not requiring an explicit call to it. |
I'm open to reverting this. With the interest in removing/reducing I wonder if that Preferences idea I mentioned above might be a viable way of approaching this compromise from another (better) direction?
This is how I originally wanted to approach this, but it's not entirely straightforward which makes me slightly wary. For instance, we could just add it to the printing in Loading on first printing/ |
I don't think the lazy init approach solves our original problem, which was minimize the "surface area" of StyledStrings, esp. w.r.t. to code size + dependencies. I'm not sure the TOML parser is actually a very heavy dependency w.r.t. code size (it's self-contained and a pretty simple grammar/spec) - might be worth a measurement. But it does seem undesirable to have, e.g., all Julia-built CLI apps dynamically loading StyledStrings faces on startup / first print. |
TBH, I feel skeptical about the global It seems like it creates a namespacing problem. If I called Even providing a global dictionary of Faces as a TOML seems challenging to me. If the "theming" included a standard set of Face names, so that the intended purpose of each I feel like instead of working with a global dictionary of Faces, this feature should either (a) be removed, or (b) be reworked to work in terms of complete "palettes" instead of a global dictionary of Faces. |
Cody and I have have had a chat about the concerns he raised in the above comments, and I think it's fair to say that we both see the single global faces dict as non-ideal, but not a terrible compromise. He's proposed an idea of "Palettes" that we're both interested in exploring and could come along in the future. This is separate to the near-term future of the changes that Kristoffer has expressed dissatisfaction with. From here, our options are to:
The relevant considerations I'm aware of currently are:
This makes me wonder if perhaps a good (4) would be something like this (it it possible?) @static if !we_are_static_compiling()
const __init__ = load_customisations!
end |
I think #94 should resolve this decently well 🙂. |
This is primarily motivated by reducing the amount of work that trimming is unable to remove.
It will require applications (by which I mean the actual thing that uses
StyledStrings
, for example the REPL) to callload_customisations!
itself. If there's a good spot to add that so it automatically gets done "at the right time, when appropriate to do so" that would be even better, but I'm not sure there's an obvious spot that can be done without the potential for headaches (e.g. what if it comes up within awithfaces
call).For now at least, perhaps this is a reasonable compromise.