[#86520] [Ruby trunk Bug#14681] `syswrite': stream closed in another thread (IOError) — samuel@...
Issue #14681 has been reported by ioquatix (Samuel Williams).
3 messages
2018/04/12
[#86755] [Ruby trunk Feature#14723] [WIP] sleepy GC — normalperson@...
Issue #14723 has been reported by normalperson (Eric Wong).
6 messages
2018/04/29
[ruby-core:86694] [Ruby trunk Feature#14701] If the object is not frozen, I want to be able to redefine the compound assignment operator.
From:
nobu@...
Date:
2018-04-26 08:56:07 UTC
List:
ruby-core #86694
Issue #14701 has been updated by nobu (Nobuyoshi Nakada).
masa16 (Masahiro Tanaka) wrote:
> Former NArray had `add!` method, but it results in a confused result.
It seems a different story from `+=`.
> ~~~ 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,2).indgen!
> a[0,true].add!(10)
> p a
> # => NArray.int(2,2):
> # [ [ 0, 1 ],
> # [ 2, 3 ] ]
> ~~~
It feels that `a[0,true]` should return `inplace` object.
Otherwise `+=` would not be possible to modify `a` itself too, even if it were differentiated.
----------------------------------------
Feature #14701: If the object is not frozen, I want to be able to redefine the compound assignment operator.
https://bugs.ruby-lang.org/issues/14701#change-71653
* Author: naitoh (Jun NAITOH)
* Status: Rejected
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
If the object is not frozen, I want to be able to redefine the compound assignment operator (e.g. +=, -=, *=, /=, ..etc ).
https://docs.ruby-lang.org/ja/latest/doc/spec=2foperator.html
* Redefinable operator (method)
~~~
| ^ & <=> == === =~ > >= < <= << >>
+ - * / % ** ~ +@ -@ [] []= ` ! != !~
~~~
* use case
~~~
> require 'numo/narray'
> a = Numo::Int32[5, 6]
=> Numo::Int32#shape=[2]
[5, 6]
> a.object_id
=> 70326927544920
> a += 1
=> Numo::Int32#shape=[2]
[6, 7]
> a.object_id
=> 70326927530540
> a.inplace + 1
=> Numo::Int32(view)#shape=[2]
[7, 8]
> a.object_id
=> 70326927530540
~~~
With Numo::NArray, using "inplace" instead of "+=" will update the same object so it will be faster.
I want to write "a += 1" instead of "a.inplace + 1".
However, Ruby can not redefine "+=".
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>