Skip to content

Consider implements MyInterface syntax #14

Description

@amomchilov

Would we want this?

module Notifier
  interface!

  # ...
end

class SlackNotifier
  implements Notifier # ✨
  
  # ...
end

The implementation would literally just be Module.alias_method(:implements, :include)

Pros:

  1. Reads really nicely, feels native
  2. Tools can instantly know that Notifier is an interface, without needing to resolve it first (it likely lives in another file)

Cons:

  1. Would need special support in Rubydex/RubyLSP. It wouldn't be understood by other tools by default.
    • Most tools that handle Ruby understand module inclusion, so they'd know the interface's methods become available on the class. They wouldn't know that about this implements keyword without having bespoke support built for it.

Originally posted by @amomchilov in #2 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions