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

Unify #inspect output formatting in several places #5858

Merged
merged 1 commit into from Apr 28, 2018

Conversation

Sija
Copy link
Contributor

@Sija Sija commented Mar 23, 2018

Reference: #<Type …>
Struct: Type(…)

@Sija Sija changed the title Unify #inspect outut formatting in several places Unify #inspect output formatting in several places Mar 23, 2018
@@ -61,11 +61,11 @@ class Time::Location
end

def inspect(io : IO)
io << "Time::Zone<"
io << "Time::Zone("
io << offset
io << ", " << name
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are here, they can be merged to io << "Time::Zone" << offset << ", " << name

Copy link
Member

Choose a reason for hiding this comment

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

@j8r I don't think that would be an improvement.

@@ -74,12 +74,12 @@ class Time::Location
getter? standard, utc

def inspect(io : IO)
io << "Time::ZoneTransition<"
io << "Time::ZoneTransition("
io << '#' << index << ", "
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

size.times do |i|
io << " "
io << " " if i > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the space string can be replaced by a char ' '

src/file/stat.cr Outdated
io << "#<File::Stat"
io << " dev=0x"
io << "File::Stat("
io << "dev=0x"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be merged to io << "File::Stat(dev=0x"

Copy link
Contributor Author

@Sija Sija Apr 11, 2018

Choose a reason for hiding this comment

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

IMHO that just looks weird, especially since there are lines below having such format.

Copy link
Member

Choose a reason for hiding this comment

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

Why weird? Aesthetics? I don't see why these strings should not be combined.

io << name_table.fetch(i, i) << ":" if i > 0
self[i]?.inspect(io)
end
io << ">"
io << ")"
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto, can be a char

size.times do |i|
io << " "
io << " " if i > 0
io << name_table.fetch(i, i) << ":" if i > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

":" => ':'

Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

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

Just a few details to improve implementation, but otherwise looks good.

src/file/stat.cr Outdated
io << "#<File::Stat"
io << " dev=0x"
io << "File::Stat("
io << "dev=0x"
Copy link
Member

Choose a reason for hiding this comment

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

Why weird? Aesthetics? I don't see why these strings should not be combined.

size.times do |i|
io << ' '
io << ' ' if i > 0
Copy link
Member

Choose a reason for hiding this comment

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

Could be combined with the following line to avoid i > 0 twice.

size.times do |i|
pp.breakable
pp.breakable if i > 0
Copy link
Member

Choose a reason for hiding this comment

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

Put this line in the else branch to avoid comparing twice.

@@ -61,11 +61,11 @@ class Time::Location
end

def inspect(io : IO)
io << "Time::Zone<"
io << "Time::Zone("
io << offset
io << ", " << name
Copy link
Member

Choose a reason for hiding this comment

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

@j8r I don't think that would be an improvement.

Copy link
Member

@asterite asterite left a comment

Choose a reason for hiding this comment

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

Nice! But needs a rebase...

Reference#inspect: `#<Type …>`
Struct#inspect: `Type(…)`
@Sija
Copy link
Contributor Author

Sija commented Apr 28, 2018

@asterite rebased.

@asterite asterite requested a review from RX14 April 28, 2018 15:13
@RX14
Copy link
Contributor

RX14 commented Apr 28, 2018

Is it really only regex match data? cool

@RX14 RX14 merged commit 9ba1ee8 into crystal-lang:master Apr 28, 2018
@RX14 RX14 added this to the Next milestone Apr 28, 2018
chris-huxtable pushed a commit to chris-huxtable/crystal that referenced this pull request Jun 6, 2018
Reference#inspect: `#<Type …>`
Struct#inspect: `Type(…)`
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