Recently in Ruby Core - June edition
Recently in Ruby Core- June Edition
Many Ruby developers don’t have time to keep up to date with the recent developments inside Ruby core. To make this easier I decided to write up the most recent progress that is happening inside the Ruby Bug tracker. I won’t summarize bug tickets, but only feature proposals. But if an important Bug ticket rises I will mention it at the end.
Here are the most important issues being discussed in the month of June:
This is one very interesting patch as it promises a lot for the future! The issues does an excellent job of explaining what object shapes are and what the value of this feature is, so I won’t repeat it here. Just a short TL;DR: This will potentialy increase the performance of the Ruby VM because the cache can be used more often and runtime checks will decrease. If you want more information about this topic I recommend to watch this talk from a recent Ruby conf.
This issue brought up a log standing pain point for many Rubyist’s. As the title tells the
Queue#pop method is about to receive a new keyword argument. With the timeout argument the user can set a may timeout period to receive the next entry of a queue.
There was some discussion about the return value if the timeout actually fulfills and most likely it will be a
nil. Matz already approved this issue, so we can hope for this in the next Ruby version.
Related to above issue here is a discussion about a general solution for the timeout problem. According to Redmine Koichi is assigned to this task, so we might get a solution for this soon as well.
Add an Array#undigits that compliments Integer#digits
This feature proposal would be a more user facing feature. The feature does exactly what you would expect, it adds the
undigits method to the array class. This is mainly a convenient method so that you can easily create an integer from an array like
If this proposal is rejected, there is an easy solution mentioned in the discussion:
[1,2,3].reverse.reduce(0) do |acc, digit| raise MathDomainError, 'out of domain' if digit.negative? acc * base + digit end
Kernel#then to take arguments
Here is a discussion about adding optional arguments to the
Kernel#then method. The author of this issue makes some valid points why this can be nice, but Eregon is making some good counter argument as well.
Named ripper fields
This issue isn’t new, but the discussion continued. In a recent dev meeting Matz and co talked about it and some questions emerged which are answered now. I wrote up a short explanation here for the issue when it was created.
Enhancements to prettyprint
This issue was also resolved and is rejected.
Here Sawada brings up a point that it is common to use wrong memoization methods when the value can be false/nil. For a solution he proposes a change to the
instance_variable_set. In the discussion it was pointed out that this still might be to limited and a gem was mentioned that could solve this issue.
The final issue that was discussed about in June was about adding the
ceildiv method to the numeric class. This method can come in handy if you want to display the number of pages for a paginated site. E.g. you have 123 items of a list and you are displaying 10 items per page. How many pages do we have here?
123.ceildiv(10) will give us an easy answer. (Which in our case is of course 13.)