-
Notifications
You must be signed in to change notification settings - Fork 52
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
Show name of currently executing function in the robot panel #2133
Comments
Annotating each |
Is that done on this line?
I'd want to distinugish between variables that refer to "toplevel function definitions" vs. variables that refer to local definitions. Is that distinction tracked in the |
Hmm, yes, that's the line I had in mind, but now that I think about it, this won't work. When we look up a variable in the environment, it is already evaluated; at some later point we may execute it (if it is a command) or reduce it (if it is a lambda that ends up getting applied to an argument) but in any case that happens at some later point unrelated to when the variable lookup happened. Maybe annotating all terms would actually be the right way to accomplish this... Regardless of how we accomplish it, I do worry that this feature might be difficult to maintain if we start doing more code optimization, see e.g. #1563 .
It is not, but I don't think it would be too hard to enhance |
IIRC, the |
Terms have their type annotations erased before putting them in the CESK machine, but I think they still have
Not unless you keep the original source code around somewhere. And keep in mind that function definitions in scope could also come from some file that was |
Thinking about this a bit more, as a user of this functionality there should be clarity around what it means to be "in a function", or what is the "currently executing function". Potentially one way to render the information would be as a "call stack". However, given TCO and infinite recursion as standard practice, a "stack" representation is less accurate/useful. I think, as a developer, the most useful thing we could get out of this is a trail of "breadcrumbs" that indicate when a function of To implement this, we would could have a |
That sounds like a nice idea in theory. I agree the notion of a "call stack" or "currently evaluating/executing function" might be a bit ill-defined. I note, however, that inserting a
|
How about adding a def trace : Cmd a -> Cmd Unit = \c.
try {
log ("STARTED " ++ __func__); c; log ("FINISHED " ++ __func__)
} { log ("FAILED " ++ __func__) }
end
def on : Int -> Cmd Unit -> (Int -> Cmd Unit) = \x. \c. \y. if (x == y) {c; c; c} {} end
def f : Int -> Cmd Unit = \i. trace (on 3 move i) end EDIT: We could add
Bonus points for |
But implementing |
I meant it to be set to the name of the definition where it is used, but I did not realize that If the |
Ugh, that sounds horrid, because the meaning of |
Even without macros, having @byorgey I guess we could replace this identifier after parsing so that it would be comparably easy to implement. |
Towards #1341. Should also be useful for #2133. ![Screenshot from 2024-09-09 22-04-10](https://github.com/user-attachments/assets/f2813cb0-be12-4299-8e4b-e745e930427e) Uses the [`brick-tabular-list`](https://hackage.haskell.org/package/brick-tabular-list) package to render the <kbd>F2</kbd> robots dialog as a navigable list with tabular formatting. Hitting <kbd>Tab</kbd> on a selected row shows details for that robot. Also: * Extracts some record definitions from `Swarm.TUI.Model.UI` into `Swarm.TUI.Model.UI.Gameplay` * Removes re-export of the `Name` type from `Swarm.TUI.Model` * Replace uses of `maximum` with the safer `maximum0` * New `applyJust` combinator ## Testing ### Showing a large robots list ``` scripts/play.sh -i data/scenarios/Challenges/Ranching/beekeeping.yaml --debug all_robots --speed 2 --autoplay ``` and with extra column: ``` scripts/play.sh -i data/scenarios/Challenges/Ranching/beekeeping.yaml --debug all_robots,robot_id --speed 2 --autoplay ``` ### Showing a small robots list with details view and logs ``` scripts/play.sh -i data/scenarios/Testing/562-lodestone.yaml --debug all_robots,robot_id --speed 2 --autoplay ``` Log view: ![Screenshot from 2024-09-13 17-25-23](https://github.com/user-attachments/assets/17e3fb6d-5d86-48b6-aeac-db28f37ae854)
While developing a scenario, it would be useful for debugging to be able to see which function a system robot is currently "in" as it executes its program.
Sometimes to achieve this I have placed a
say "function_name";
at the top of each function in a robot's program (i.e. "printf debugging") to accomplish this. But it would be nice to have an automatic mechanism.I imagine it is feasible:
Term
with the closest "function definition" that contains it.machine
and display the function name for the currently focused term in the F2 dialog.The text was updated successfully, but these errors were encountered: