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

Let p use inspect, pp just pretty print values, and introduce p! and pp! which also show the expression to print #6044

Merged
merged 1 commit into from May 2, 2018

Conversation

asterite
Copy link
Member

@asterite asterite commented May 1, 2018

Fixes #6019

…` and `pp!` which also show the expression to print
@oprypin
Copy link
Member

oprypin commented May 1, 2018

@asterite
Copy link
Member Author

asterite commented May 1, 2018

If examples used pp and now the behaviour changes, it not a big deal. In fact, in the two occurrences I found it only receives one argument, so the printed expression is really not needed in the output (and this is one of the things that couldn't easily be done before this PR).

@oprypin
Copy link
Member

oprypin commented May 1, 2018

I just mean that they should be updated, because their comments show output incorrectly.

@asterite
Copy link
Member Author

asterite commented May 1, 2018

Oh, I didn't see the output. Yeah, the should eventually be updated.

@j8r
Copy link
Contributor

j8r commented May 1, 2018

Please @asterite use a letter instead of !, we have the choice in the alphabet (like i).

When I see a bang for me the method needs to be used we caution, because it has a special behavior. This isn't the case here.

@asterite
Copy link
Member Author

asterite commented May 1, 2018

So...

a = [1, 2, 3]
a.map! { |x| x + 2 }

How is map! dangerous? Because it mutates a? Then the whole language is dangerous, everything keeps mutating.

The ! just means an alternative behaviour for a method. Rails choose to run validations on models. Ruby chose mutate or not mutate. Here we choose something different. Really, it's not a big deal, this is just for debugging purposes.

@asterite
Copy link
Member Author

asterite commented May 1, 2018

Plus we can change it later if we want to, because it can almost never be a serious breaking change because it's only used for debugging.

@oprypin
Copy link
Member

oprypin commented May 1, 2018

I dislike having 4 different methods, but 4 methods is what was agreed on in the issue.
Among the ways to name them, the one in this PR is my favorite, so I begrudgingly approve.

Copy link
Contributor

@ysbaddaden ysbaddaden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

@asterite asterite merged commit 73d3a85 into crystal-lang:master May 2, 2018
@RX14 RX14 added this to the Next milestone May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants