Bug #10086
closed[PATCH] Remove exponents calculation from mathn.rb
Description
#English
When we override :**
, we make it alias as :power!
(mathn.rb:L73, L102)
Like this.
alias power! ** unless method_defined? :power!
If user have define :power!
, this :power!
is called unintentionally.(mathn.rb:L82, L111)
def ** (other)
if self < 0 && other.round != other
Complex(self, 0.0) ** other
else
power!(other)
end
end
Now that we can do such a exponents calculation without mathn
, we don't need exetend :**
in mathn.
That's why I remove :**
from mathn.rb
#日本語
mathn.rb で :**
を上書きする際に元の :**
を :power!
としてaliasを貼っていますが、(mathn.rb:L73, L102)
alias power! ** unless method_defined? :power!
使用者が #power!
を定義していた場合、
(mathn.rb:L82, L111)
def ** (other)
if self < 0 && other.round != other
Complex(self, 0.0) ** other
else
power!(other)
end
end
の部分で意図せず利用者が定義した:power!
が呼ばれ可能性があるため、
またそもそもこの種の冪乗演算は mathn
を必要とせずとも現在は実現されているため、
:** を mathn
から削除致しました.
Files
Updated by gogotanaka (Kazuki Tanaka) over 9 years ago
- File Remove_Fixnum#power_from_mathn.patch Remove_Fixnum#power_from_mathn.patch added
- File Remove_Bignum#power_from_mathn.patch Remove_Bignum#power_from_mathn.patch added
- File Remove_Float#power_from_mathn.patch Remove_Float#power_from_mathn.patch added
- File Remove_Rational#power_from_mathn.patch Remove_Rational#power_from_mathn.patch added
- File Fix_comment_at_mathn.patch Fix_comment_at_mathn.patch added
There are my PATCHES.
PATCHです.
Updated by nobu (Nobuyoshi Nakada) over 9 years ago
- Status changed from Open to Feedback
**
の削除は(alias / quo
の変更は不要に見えますが)いいと思います。
最後のパッチで"multiple division"から"multiple"という単語が消されていますが、これはいらないのでしょうか。
Updated by gogotanaka (Kazuki Tanaka) over 9 years ago
@Nobuyoshi Nakada さん
コメントありがとうございます.
alias / quo の変更は不要に見えますが
個人的にaliasを貼る時は(特にoperatorに対して)symbolの方が可読性が高まり好ましいと考えています.
すみませんこの様な個人的な趣向を入れ込むは避けるべきだったでしょうか.
少なくともパッチは分けるべきだったでしょうか.
最後のパッチで"multiple division"から"multiple"という単語が消されていますが、これはいらないのでしょうか。
はい. 文脈から察するに'多様な除法' を意図された言葉だと思いますが、
multiple division という表現は聞いた事がありませんし、多元や多分烈という言葉を連想されやすと思います.
gogo.
Updated by mame (Yusuke Endoh) over 9 years ago
よこやりですが、
If you need
more precise rounding with multiple division or exponentiation
operations, then mathn is the right tool.
という rdoc はそもそも不自然だと思います。
3 / 2 が 1 ではなく Rational(3, 2) になるということを
more precise rounding とは言わないと思います。
rounding はふつう四捨五入とかの丸めを意味しますが、
後者はそもそも rounding してないので。
--
Yusuke Endoh mame@ruby-lang.org
Updated by gogotanaka (Kazuki Tanaka) over 9 years ago
- File improve_rdoc_mathn_l8.patch improve_rdoc_mathn_l8.patch added
- File improve_rdoc_mathn_l20.patch improve_rdoc_mathn_l20.patch added
@Yusuke Endoh さん
よこやりありがとうございます.
はい. 全くもって正しいご指摘だと思います. すみません僕が修正する際に気づくべきでした.
引き合いに出された文全体を
mathn serves to make mathematical operations more precise in Ruby
and to integrate other standard libraries.
にまた、別の部分(mathn.rb:L20)で
mathn features late rounding and lacks truncation of intermediate results:
という表現があったので
mathn keeps value in exact terms.
に変更致します.
gogo.
Updated by nobu (Nobuyoshi Nakada) over 9 years ago
- Status changed from Feedback to Closed
- % Done changed from 0 to 100
Applied in changeset r47290.
lib/mathn.rb: remove built-in methods
- lib/mathn.rb (Fixnum#, Bignum#, Float#, Rational#):
remove as these are now built-in. [ruby-core:63973] [Bug #10086]
Updated by hsbt (Hiroshi SHIBATA) about 7 years ago
- Related to Feature #13334: Removed deprecated mathn extentions. added