You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Object dumps are great for inspecting state but when I am just setting up the state and performing a series of commands, each of which returns a complex object with a multi-page dump, that gets annoying fast. It would be nice if the interpreter would recognize which commands are not meant for inspection (commands including an assignment operator would be a decent first approximation) and use a short version of the dump (probably just the class name would work well enough) in that case.
You can follow the command with another command. PsySH only prints the value of the last statement it executed. e.g.:
>>> thing_which_returns_a_lot_of_state();1;
1
The interpreter would be making quite the assumption to decide that a given result wasn't intended for inspection. There would need to be a way of ensuring that the full dump was at least optionally printed.
Is there currently a way to re-print the most recent return value? An interesting approach might be to print the "short version" by default, but have a command to re-print the last value in full. dump seems to require an argument, so re-printing the most recent value could become the behaviour when no argument was provided?
Is there currently a way to re-print the most recent return value?
Yeah, dump $_. But the more intuitive (to me) version is
$foo = someCommand();
$foo
where the second command can't have any other possible reason than inspection. Similarly a command like $foo['bar'][$baz] is no doubt used for inspection. So either using a full dump when there is no assignment, or using it when there is no assignment and no function/method call (ie. no side effect) feels natural to me.
The implicit dump for return values is supposed to be printing a short dump. The dump command is there if you want more info. If it's not doing that now, we should fix it :)
Object dumps are great for inspecting state but when I am just setting up the state and performing a series of commands, each of which returns a complex object with a multi-page dump, that gets annoying fast. It would be nice if the interpreter would recognize which commands are not meant for inspection (commands including an assignment operator would be a decent first approximation) and use a short version of the dump (probably just the class name would work well enough) in that case.
#218 is sort of related.
The text was updated successfully, but these errors were encountered: