General

Profile

masa16 (Masahiro Tanaka)

Issues

open closed Total
Assigned issues 0 0 0
Reported issues 0 1 1

Activity

04/27/2018

10:19 PM Ruby Feature #14701: If the object is not frozen, I want to be able to redefine the compound assignment operator.
Alternative idea: If Ruby has a feature like:
~~~ ruby
x = x.left_variable? # => true
y = x.left_variable? # => false
~~~
then inplace operation is possible without redefinition of `+=`.
masa16 (Masahiro Tanaka)

04/26/2018

09:30 AM Ruby Feature #14701: If the object is not frozen, I want to be able to redefine the compound assignment operator.
I think it is enough to change the meaning of
~~~ ruby
x += a
~~~
to
~~~ ruby
if x.respond_to?(:'+=')
x.send(:'+=',a)
else
x = x + a
end
~~~
Matz rejected this in http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...
masa16 (Masahiro Tanaka)
09:28 AM Ruby Feature #14701: If the object is not frozen, I want to be able to redefine the compound assignment operator.
nobu (Nobuyoshi Nakada) wrote:
> It seems a different story from `+=`.
I am sorry for getting off the point, but I wanted to say that `add!` method does not solve the problem.
> ...
This cannot be a solution because both inplace a...
masa16 (Masahiro Tanaka)
01:17 AM Ruby Feature #14701: If the object is not frozen, I want to be able to redefine the compound assignment operator.
Former NArray had `add!` method, but it results in a confused result.
~~~ ruby
require 'narray'
a = NArray.int(2,2).indgen!
a[1,true] += 10
p a
# => NArray.int(2,2):
# [ [ 0, 11 ],
# [ 2, 13 ] ]
a = NArray.int(2,...
masa16 (Masahiro Tanaka)

12/26/2016

01:23 PM Ruby Bug #13076 (Closed): SEGV in io.c when reading closed stream in Thread
System: CentOS Linux release 7.3.1611 (Core)
Kernel: 3.10.0-514.2.2.el7.x86_64
GCC: gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
The following script crushes with ruby 2.4.0, 2.3.3 and 2.2.6.
~~~ ruby
100.times do |i|
...
masa16 (Masahiro Tanaka)

10/02/2011

06:53 PM Ruby Bug #4576: Range#step miss the last value, if end-exclusive and has float number
2011/9/17 Masahiro TANAKA <masa16.tanaka@gmail.com>:
> --- numeric.c (revision 33288)
> ...
This patch involves a problem:
a=(1.0..1-2e-16).step(1.0).to_a; p a #=> [1.0] ; should be []
The following patch would be better.
--- numeri...
masa16 (Masahiro Tanaka)

09/21/2011

09:29 PM Ruby Bug #4576: Range#step miss the last value, if end-exclusive and has float number
I haven't explained the reason of the error estimation in
Range#step for Float;

double n = (end - beg)/unit;
double err = (fabs(beg) + fabs(end) + fabs(end-beg)) / fabs(unit) * epsilon;

The reason is as follows...
masa16 (Masahiro Tanaka)
07:23 PM Ruby Bug #4576: Range#step miss the last value, if end-exclusive and has float number
2011/9/20 Tanaka Akira <akr@fsij.org>:
> However the algorithm doesn't solve [ruby-core:39602] and [ruby-core:39606].
>
> % ./ruby -e 'a = (1.0..12.7).step(1.3).to_a; p a.all? {|n| n <= 12.7 }, a.last'
> false
> 12.70000000000...
masa16 (Masahiro Tanaka)

09/17/2011

07:23 PM Ruby Bug #4576: Range#step miss the last value, if end-exclusive and has float number
I have not been watching ruby-core, but let me give a comment for this issue.
I proposed Numeric#step algorithm for Float in [ruby-dev:20177],
but that was only for the include_end-case.
> (1...6.3).step.to_a # => [1.0, 2.0, 3.0, 4.0, ...
masa16 (Masahiro Tanaka)

Also available in: Atom