Comments (6)
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.
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.
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.
+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.
(I cannot find the english version.)
Although the instance methods of
Object
are defined by theKernel
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)
- Feature proposal: `rbs diff` command HOT 1
- Feature proposal: `rbs todo` command
- Should gems include private methods and constants in their RBS files? HOT 1
- Allow Type Variable constraints to be arbitrary types HOT 1
- `Enumerable#to_set` accepts a block
- `SimpleDelegator` is missing HOT 1
- URI is missing HOT 3
- Logger is missing
- Set#intersect?, Set#disjoint? signatures are too narrow HOT 1
- The `range[T]` type definition is to restrictive
- `_Range[T]` shouldn't return `T?` for `begin` and `end`
- override a function with a block fails
- Singleton does not have method `instance` HOT 1
- add an `assert_const_type`
- Cannot specify type variables for `instance` HOT 6
- manifest.yaml does not allow gems as dependencies
- Proposal: making `Class` and `Module` classes generic -- `Class[I]` and `Module[I]` HOT 9
- Feature proposal: Multiple error on `rbs validate` HOT 1
- stringio should be a stdlib, but it's in `core/`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rbs.