-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_Callable interface in builtin #420
Comments
Maybe, but very few builtin methods take such a parameter. I can think of Note that the return type should not be interface _Call
def call: (*top) -> top
end Still, it might be best not to, since the above interface is too lax, usually you will want to specify the type of inputs the |
In the benefit of understanding, what does "top" stand for? I struggled a bit with the meaning of it. Perhaps you're right, but a Callable with a T reference seems more suitable to my example. All things considered I might backtrack a bit on this until I come up with compelling use cases. |
If you have a specific method in your mind, like interface _NotFound[A]
def call: () -> A
end
module Enumerable[X, Y]
def find: [T] (_NotFound[T]) -> (X | T)
...
end |
I had this in mind: https://docs.python.org/3/library/typing.html#callable |
After thinking more about this, I think that I do not necessarily want a Callable interface, rather an "inline" way of saying "something implementing #call", i.e. I think that rbs could have syntactic sugar for defining these 1 method-interfaces.
How that would look like, I have no idea :) |
I was looking at https://github.com/ruby/rbs/blob/c64d1f5ba5a4fbc95ffb1d72d783ee39b17d60fe/stdlib/builtin/builtin.rbs, where a lot of common knownn interfaces are stored. I was wondering whether there should be one for "callable" objects, that is: implements
#call
. Objects implementing this interface can already be passed to places where are expected, for example.The text was updated successfully, but these errors were encountered: