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

Ruby 2.3 preparedness #335

Closed
AaronLasseigne opened this issue Dec 17, 2015 · 3 comments
Closed

Ruby 2.3 preparedness #335

AaronLasseigne opened this issue Dec 17, 2015 · 3 comments
Assignees
Labels

Comments

@AaronLasseigne
Copy link
Owner

With 2.3 around the corner we need to make sure the code works. Right now all tests pass in 2.3 (run locally) and I don't see anything that should cause us problems. We need to make sure 2.3 is added to our Travis CI runs when it becomes available.

Ruby 2.3 is introducing a pragma to make all strings immutable by default. The though is that by Ruby 3 this will be standard. It works by adding # frozen_string_literal: true to the top of the file. Then all strings created using single or double quotes are immutable. If you need a mutable string it will need to be created using String.new.

I would like to adopt the new pragma so that people using 2.3 can get the performance benefit and we're ready for Ruby 3 ahead of time. @tfausak thoughts?

@AaronLasseigne
Copy link
Owner Author

One thing to consider is that we need to make sure the string coming back from a string filter is mutable. That would be an unexpected surprise for people.

@tfausak
Copy link
Collaborator

tfausak commented Dec 17, 2015

Instead of adding the pragma, why don't we .freeze all our literal strings? That way previous versions would get frozen strings and we would accidentally give frozen strings back to the user.

@tfausak
Copy link
Collaborator

tfausak commented Dec 17, 2015

On second thought, freezing every string is going to be super annoying. They are created in a variety of ways that are hard to grep for. You've got normal string literals, which can be delimited with ' or '" or % and friends, and then you've got string array literals, which can be %w and friends. And then you've got things that happen to return strings, like to_s and inspect. I'd rather let the magic comment take care of things.

That being said, I think we should benchmark our codebase against 2.3 with and without frozen strings. It might not make much of a difference.

@tfausak tfausak self-assigned this Dec 17, 2015
tfausak added a commit that referenced this issue Dec 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants