Feature Request: Interfaces should suppport ivars

Aperta
#3,265 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
ruby
Ambito
tooling

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Ruby
Stelle
2.2k
Fork
260
Merge medio
22h 3m
PR unite (30g)
54

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ruby/rbs

Tutte le issue di ruby/rbs

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.