Git Product home page Git Product logo

Comments (6)

ksss avatar ksss commented on June 16, 2024 1

Thank you for the comment. It seems we can call super with top-level redefinitions. Interesting.

p method(:puts)
#=> #<Method: Object(Kernel)#puts(*)>

def puts(*)
  print "before\n"
  super
  print "after\n"
end

puts "hello"
#=> before
#=> hello
#=> after

p method(:puts)
#=> #<Method: Object#puts(*) t.rb:1>

p method(:puts).super_method
#=> #<Method: Kernel#puts(*)>

from rbs.

ParadoxV5 avatar ParadoxV5 commented on June 16, 2024

That’s a Ruby implementation problem ¯\_(ツ)_/¯

Object.instance_methods(false) #=> []

Everything is actually all defined in Kernel, with Object merely BasicObject + Kernel.
The API docs put instance methods (as opposed to utility functions like print) on the Object page for our convenience (read: façade). RBS just followed suit.

P.S. IMO, those methods listed should not only be on Object’s RBS page, but also actually define under Object rather than Kernel, as Object is a class and Kernel sounds more like a utils package. Unfortunately, it’s probably all hard-to-refactor ancient code at this point.

from rbs.

ksss avatar ksss commented on June 16, 2024

I found this PR. #86

@soutaro
Do you still think the same way?
I am concerned about the meaning of RBS as a document.

from rbs.

soutaro avatar soutaro commented on June 16, 2024

+1 for moving those methods to ::Kernel. (But when?)

When #86 was composed, we didn't have %a{annotate:rdoc:copy:???} annotation. But today we have, and we can have the RBS definitions in Kernel while it copies the docs form Object methods.

The doc says:

Object クラスのメソッドは実際にはこのモジュールで定義されています。これはトップレベルでのメソッドの再定義に対応するためです。 https://docs.ruby-lang.org/ja/latest/class/Kernel.html

(I cannot find the english version.) Methods of Object class are actually defined in this module. This is for over-writing methods in top-level.

So, for this purpose, RBS definition should be in Kernel module too. (While it's not very clear to me what it means... Does it mean we can call the originals with super ??)

from rbs.

ParadoxV5 avatar ParadoxV5 commented on June 16, 2024

(I cannot find the english version.)

Although the instance methods of Object are defined by the Kernel module, we have chosen to document them here for clarity.
Object


Truthfully, [P.S. given that it’s probably all hard-to-refactor ancient code at this point,] I too prefer everything defined under Kernel to document in Kernel to represent how things are done. But Team Core had reasons.
In the mean time, I also prefer RBS to match the Ruby docs (whether they decide Object or Kernel) for consistency.

from rbs.

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.