Giter VIP home page Giter VIP logo

Comments (4)

duerst avatar duerst commented on May 26, 2024

First, the original issue text is very short, so I'm copying it here:
「Math.sqrt との対称性から、BigDecimal#sqrt は BigMath.sqrt として提供すべきでしょう。」
In other words, "BigDecimal#sqrt should be moved to BigMath.sqrt to be symmetric (parallel?) to Math.sqrt".

I don't mind aligning the interfaces, but I think it should be the other way round. With Ruby being such a thoroughly object-oriented language, I have never understood why I would have to write
Math.sqrt(25) when 25.sqrt would be much shorter, more convenient, and more Ruby-like.

My guess is that the reason for the functions being in the Math module are mostly historic. It's definitely not a question of memory footprint, because the Math module is built-in and doesn't have to be required.

[We may have to move this issue back to https://bugs.ruby-lang.org/issues/4968 because if done well, it will affect Ruby itself, too.]

from bigdecimal.

mrkn avatar mrkn commented on May 26, 2024

@duerst sqrt is a mathematical function.
I think most people, including me, want to write sqrt(25) instead of 25.sqrt because the former notation is more natural in math than the latter.

from bigdecimal.

duerst avatar duerst commented on May 26, 2024

@mrkn I don't mind if some people sometimes want to write sqrt(25); I might want to do that occasionally, too.

But this is Ruby, and as a Rubyist, I feel quite okay with 25.sqrt. Actually, I feel more than just right, I feel that it's very natural.

Even more, if sqrt is a method on numeric objects, I can do things like array.map &:sqrt. With the functional notation, that doesn't work.

If we want Ruby to be used more for numerical computation and similar applications, then making people familiar with Math feeling familiar with Ruby may be an important point, but we also have to make sure that these people can use Ruby to the fullest.

from bigdecimal.

mrkn avatar mrkn commented on May 26, 2024

@duerst Now Ruby's core numeric class don't have sqrt as their instance methods.
As a maintainer of BigDecimal, I think I should let BigDecimal follow to core numeric classes.
It is the purpose of this issue.

It means that I will keep BigDecimal#sqrt if core numeric classes have sqrt instance methods.

But I don't want to write 25.sqrt, so I won't create the new issue to propose sqrt instance methods in core numeric classes.
Please create the new issue and discuss it in bugs.ruby-lang.org If you want.

from bigdecimal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.