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

Rename MemoryIO to IO::Memory #3401

Closed
wants to merge 1 commit into from
Closed

Conversation

RX14
Copy link
Contributor

@RX14 RX14 commented Oct 9, 2016

With IO::Delimited, IO::Hexdump etc. IO::Memory seems like a much more consistent name than MemoryIO.

@RX14 RX14 force-pushed the rename-memoryio branch 2 times, most recently from dfd7ba0 to 349ac1d Compare October 9, 2016 15:26
@RX14
Copy link
Contributor Author

RX14 commented Oct 10, 2016

This PR is obviously going to become out of date quite quickly as MemoryIO is used very often, so it would be a good idea to make a decision on this sooner rather than later.

@asterite
Copy link
Member

I also think it's more consistent with the other IOs, but typing IO::Memory is a bit slower than typing MemoryIO. Nevertheless I agree it would be convenient to make the change. I'll check with @waj this week.

@ysbaddaden
Copy link
Contributor

Same here. MemoryIO reads better than IO::Memory, but the same can be said of IO::Delimited, IO::Buffered... so it would fit better.

@asterite
Copy link
Member

Well, we could rename IO::Delimited to DelimitedIO, etc. I actually think that this is a better change. IO::Memory is not a memory. We have Char::Reader, but there it makes sense: it's a reader.

@mverzilli
Copy link

It does feel tidier to group all Crystal IO services under the same namespace. And it could get even better once we develop more advanced editor tools. Just type IO:: and you get a nice dropdown with the menu of IO resources at your service, which is an organic way of learning about the std.

@RX14
Copy link
Contributor Author

RX14 commented Oct 10, 2016

I don't feel like "typing cost" is a particularly good motivation for any change. Most time spent programming is spent looking at or thinking about code, so naming and syntax should be optimised for readability not typability. IO::Memory reads the same or better than MemoryIO to me.

@timcraft
Copy link
Contributor

How about StringIO? Easier to find for anyone coming from other languages (Ruby and Python both have StringIO), and fits with the point asterite makes about it being an IO.

@RX14
Copy link
Contributor Author

RX14 commented Oct 11, 2016

@timcraft except it's not a StringIO because it can contain raw bytes that aren't UTF-8 code points, and renaming just MemoryIO doesn't fix the inconsistency in the slightest.

@RX14
Copy link
Contributor Author

RX14 commented Oct 17, 2016

Still no movement on this? Unfortunately it's a PR that has to be merged soon after it's updated, and this PR wasn't as simple as running s/MemoryIO/IO::Memory/g on the repo.

@luislavena
Copy link
Contributor

luislavena commented Oct 17, 2016

Well, we could rename IO::Delimited to DelimitedIO, etc. I actually think that this is a better change. IO::Memory is not a memory. We have Char::Reader, but there it makes sense: it's a reader.

@asterite wouldn't this be similar to the decision of renaming BufferedChannel to Channel::Buffered and similar to UnbufferedChannel?

While type-to-result ratio for IO::Memory is more heavy, the question if is translates meaning quicker: is MemoryIO a type of IO? Is IO::Delimited similar?

Reading the documentation:

  • IO::Delimited - An IO that wraps another IO, and only reads up to the beginning of a specified delimiter.
  • MemoryIO - An IO that reads and writes from a buffer in memory.

The thing with Char::Reader can also be extended to StringPool or StringScanner, they are helpers that relates to Char or String respectively, but they are not by definition a subtype of Char or String.

IMO MemoryIO is easier to type in than IO::Memory but there are more things than typing speed to take in consideration 😄

Cheers.

@asterite
Copy link
Member

Closed by #3563

@asterite asterite closed this Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants