Feature Request: Interfaces should suppport ivars

Đang mở
#3,265 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
ruby
Lĩnh vực
tooling

Hướng nghiên cứu

Start with the interface and mixin examples in the issue, then read the referenced PR #3256 for context. Define what interface instance variables should mean for these examples and how the behavior can be validated; done means the desired semantics are clear and the proposed feature is specified.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

This is a request for an addition to the concept of Interfaces; while I get that the inspiration for RBS interfaces are Java Interfaces, where the definition of methods, and not assomuch state, is the way to define them. However, the concept is quite limiting considering what Interfaces are used for RBS/Ruby. Interfaces are the defacto way to define duck-typing. In ruby, this is not constrained to methods, specially when one considers mixins. A random example:

module IoOps
  def read_and_eval
    payload = @io.read
    # ...
  end
end
class TCPWrapper
  @io: TCPSocket
end

class SSLWrapper
  @io: OpenSSL::SSL::SSLSocket
end

# given that, I'd like to define a mixin for each
interface _IOWrapper
  @io: _ToIO # this interface should cover both tcp and ssl sockets
end


module IoOps : _IOWrapper # https://github.com/ruby/rbs/pull/3256
end

I think this type of mixins are common enough; Think about extensions which apply to different db adapters.

Ngôn ngữ chính
Ruby
Star
2.2k
Fork
260
Merge trung bình
22 giờ 3 phút
Pull request đã merge (30 ngày)
54

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ruby/rbs

Tất cả issue của ruby/rbs

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.