-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Complete Transient Stack Model #156
Comments
The example case I'm working on is to use a sub-prefix like a builder or wizard. For example, I was going to build up a new suffix (a wiki example I was building). Instead of doing multiple readers, I thought using a prefix like a builder API might better handle the large amount of optional configuration. From what I've read, sub-prefixes are mostly treated as if one-way, no-return. This means I would have to do my own plumbing both to get the data from the child and to reflect changes in the parent. While it's natural that the user needs to go get arguments to interactive functions so that they can be used standalone, I don't think it's natural to have to resort to A call stack and a data model for such a stack I think go together, and the outcome should be a little bit easier plumbing of data. I'm going to open a separate issue for handling non-argument values, but it's related to growing beyond just wrapping CLI's. |
Changed title. The very first job of this issue will be to complete the state machine implementation until:
For example, it looks like an organically grown state machine that needs to be given a total model. Without fixing that up first, changes will be hard to make without introducing bugs or even to read in PR. |
https://github.com/magit/transient/wiki/Developer-Quick-Start-Guide#errata This example encountered another edge behavior when configuring a sub-prefix to "return". Not sure it's possible with current public or private function calls to set things up so that both paths in the child prefix body will "return" to the parent prefix. |
Oh noos, you cancelled our talks? I was looking forward to that. (And all the other canceled talks are those I was looking forward to the most; what's going on here?) |
I have gotten a better understanding of both the stack mechanics and intent and think this issue has revealed itself to be poorly defined by me 🥉 |
Seems like there's some gaps in pre-commands or the stack model. There's two problems I can't quite get to work perfectly.
I've tried numerous combinations,
transient--do-stay
or invoking(transient-setup ...)
to obtain a fake "return" behavior. I can't describe all of the edges that I observed while getting these examples this far along. Let's focus on two examples that are very close to a perfect "return" while still having access to parent arguments in the sub-prefix. Neither one fully succeeds.In this first example, I want to be able to print the
transient-toys-parent
arguments from both the prefix and sub-prefix. To do this in the prefix, I need to usetransient--do-call
or else I getnil
. If I set thetransient-toys-msg-parent-args
to:transient 'transient--do-call
in the sub-prefix, the act of exporting the sub-prefix args makes the parent prefix argsnil
.This reveals the frist edge case. I cannot access the parent arguments and suffix arguments at the same time. One or the other will be
nil
In another example, we can construct a transient that returns to the parent prefix and keeps the same switch active, but it cannot message the parent arguments in both parent and sub-prefix.
My expectation is that
transient--do-replace
would not result in a "return" fromtransient--do-quit-one
. Also surprisingly,transient--do-replace
leaves the parent arguments available whiletransient--do-call
results in them being unavailable in the child and a failure oftransient--do-quit-one
to return.Recommended Path to Fix
I believe access to arguments of multiple prefixes in one suffix or prefix body should be a thing. I'm not aware of any magit examples that do this. As far as I know, they only access their immediate parent's arguments. Exporting should not necessarily change the return value of other prefixes.
New pre-commands to clear things up:
transient--do-return
should leave the arguments available and "return" to the most immediate predecessor that left itself availabletransient--do-replace
should not leave itself available for returntransient--do-call
should leave itself available for returntransient--do-replace
would become more like goto and could be used to implement recursive workflows with tail-call eliminationtransient--do-replace
could also be used to enter a sequence of sub-prefixes that finally return to the main parent prefixtransient--do-call
could be relied upon where a workflow was intended to be returned to.Supporting calls creates a problem for accessing multiple prefixes. If a user uses
transient--do-call
on the same prefix several times, we would need a stack of states. Whiletransient-args
could just return the most recent, perhaps a new function is needed to get all available states from the stack.I'll follow up later after I get some more time. It might be best to start with a total solution with less support for "goto" style navigation to avoid fragile flow control implementation. The concept in my head isn't obviously complete yet.
The text was updated successfully, but these errors were encountered: