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
[DOC] Packed data #6520
Conversation
[""].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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
[""].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" |
There was a problem hiding this comment.
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.
@peterzhu2118, I think all's well except for the overly-verbose examples you've cited. Would you pare them here in-place? |
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. |
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? |
There was a problem hiding this 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.
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.