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

[DOC] Packed data #6520

Merged
merged 11 commits into from Oct 15, 2022
Merged

[DOC] Packed data #6520

merged 11 commits into from Oct 15, 2022

Conversation

BurdetteLamar
Copy link
Member

New page for packed data, full-fledged discussion with many examples. Will provide link targets for Array#pack, String#unpack, and String#unpack1. Many examples adapted from the tests.

@BurdetteLamar BurdetteLamar marked this pull request as draft October 9, 2022 23:08
@BurdetteLamar BurdetteLamar added the Documentation Improvements to documentation. label Oct 9, 2022
@BurdetteLamar BurdetteLamar marked this pull request as ready for review October 9, 2022 23:09
doc/packed_data.rdoc Outdated Show resolved Hide resolved
doc/packed_data.rdoc Show resolved Hide resolved
doc/packed_data.rdoc Outdated Show resolved Hide resolved
doc/packed_data.rdoc Show resolved Hide resolved
doc/packed_data.rdoc Outdated Show resolved Hide resolved
doc/packed_data.rdoc Outdated Show resolved Hide resolved
doc/packed_data.rdoc Outdated Show resolved Hide resolved
doc/packed_data.rdoc Outdated Show resolved Hide resolved
doc/packed_data.rdoc Outdated Show resolved Hide resolved
Comment on lines +497 to +503
[""].pack('m') # => ""
["\0"].pack('m') # => "AA==\n"
["\0\0"].pack('m') # => "AAA=\n"
["\0\0\0"].pack('m') # => "AAAA\n"
["\377"].pack('m') # => "/w==\n"
["\377\377"].pack('m') # => "//8=\n"
["\377\377\377"].pack('m') # => "////\n"
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what the significance of showing that you can repeat the same character twice vs. thrice is? It's making the examples significantly longer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Taken straight from the tests; which should be eliminated?

Copy link
Member

Choose a reason for hiding this comment

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

I would feel it's a bit redundant if it doesn't highlight anything important. Most of the tests is more verbose than the examples we need to give.

Copy link
Member Author

Choose a reason for hiding this comment

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

Which to remove, and which to keep?

doc/packed_data.rdoc Outdated Show resolved Hide resolved
Comment on lines +497 to +503
[""].pack('m') # => ""
["\0"].pack('m') # => "AA==\n"
["\0\0"].pack('m') # => "AAA=\n"
["\0\0\0"].pack('m') # => "AAAA\n"
["\377"].pack('m') # => "/w==\n"
["\377\377"].pack('m') # => "//8=\n"
["\377\377\377"].pack('m') # => "////\n"
Copy link
Member

Choose a reason for hiding this comment

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

I would feel it's a bit redundant if it doesn't highlight anything important. Most of the tests is more verbose than the examples we need to give.

@BurdetteLamar
Copy link
Member Author

@peterzhu2118, I think all's well except for the overly-verbose examples you've cited. Would you pare them here in-place?

@peterzhu2118
Copy link
Member

I do think the examples are bit too verbose since, for me at least, longer examples require more mental capacity as I need to first understand the code, figure out how the code differs from other examples, and then understand what the example is trying to demonstrate.

On the other hand, it's difficult to suggest which examples to remove as many of them are demonstrating something different.

But I guess it's a tradeoff. Longer examples provide more coverage of corner cases at the cost of the possibility that the reader loses focus halfway. On the other hand, shorter examples have more focus on what you're trying to demonstrate at the cost of completeness.

At the end of the day, I'm not sure what the best option is. I prefer having shorter examples, but I don't have strong opinions on this.

@BurdetteLamar
Copy link
Member Author

I'm not wed to these examples, but I don't feel comfortable to winnow them by deciding which should stay/go. So, from you I request either approval or winnowing. Or perhaps someone else should look at them?

Copy link
Member

@peterzhu2118 peterzhu2118 left a comment

Choose a reason for hiding this comment

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

While I think the examples could use some trimming, I don't feel strongly about it (it's a tradeoff of completeness vs. concise). The other parts look good, so I don't block this PR solely based off that.

@BurdetteLamar BurdetteLamar merged commit 8d20632 into ruby:master Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements to documentation.
2 participants