Feature Request: Interfaces should suppport ivars

Offen
#3,265 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
ruby
Bereich
tooling

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Ruby
Sterne
2.2k
Forks
260
Ø Merge
22 Std. 3 Min.
Gemergte PRs (30 T.)
54

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus ruby/rbs

Alle Issues in ruby/rbs

Ähnliche Issues

Weitere Issues zu Ruby

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.