[#92070] [Ruby trunk Feature#15667] Introduce malloc_trim(0) in full gc cycles — sam.saffron@...
Issue #15667 has been updated by sam.saffron (Sam Saffron).
3 messages
2019/04/01
[ruby-core:92288] [Ruby trunk Feature#14701] If the object is not frozen, I want to be able to redefine the compound assignment operator.
From:
shyouhei@...
Date:
2019-04-15 07:27:26 UTC
List:
ruby-core #92288
Issue #14701 has been updated by shyouhei (Shyouhei Urabe).
So far in ruby, a variable is _not_ an object. That is the reason behind why we lack ++ operator.
naitoh (Jun NAITOH) wrote:
> I want to write "a += 1" instead of "a.inplace + 1".
Is this enough for us to depart from where we are now? The proposed change sounds something fundamental to me.
----------------------------------------
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-77624
* Author: naitoh (Jun NAITOH)
* Status: Open
* 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>