Skip to content
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 short dump on commands which do not look like they were meant for inspection #512

Open
tgr opened this issue Jul 9, 2018 · 3 comments
Labels

Comments

@tgr
Copy link
Contributor

tgr commented Jul 9, 2018

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.

@phil-s
Copy link

phil-s commented Jul 10, 2018

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?

@tgr
Copy link
Contributor Author

tgr commented Jul 10, 2018

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.

You can follow the command with another command.

Thanks, that's a nice workaround.

@bobthecow
Copy link
Owner

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 :)

@bobthecow bobthecow added the bug label Oct 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants