Skip to content

Untyped block args #1335

Closed
Closed

Description

@soutaro

AR::Base.scope accepts lambdas, but the type of the lambdas is difficult to describe in RBS.

class AR::Base
  def self.scope: (Symbol, ^(*untyped, **untyped) -> void) -> void
end

The proc type means it can receive any argument and any keywords, while what we want is a proc is required but the type of its arguments is not checked. So, we want to introduce a new syntax for untyped args.

Possible syntax:

class AR::Base
  # ...
  def self.scope: (Symbol, ^(...) -> void) -> void
                | (Symbol) { (...) -> void } -> void

  # ?
  def self.scope: (Symbol, ^(?) -> void) -> void
                | (Symbol) { (?) -> void } -> void

  # untyped
  def self.scope: (Symbol, ^untyped -> void) -> void
                | (Symbol) { untyped -> void } -> void
end

Any other ones?

Activity

  1. added this to the RBS 3.2 milestone on May 16, 2023
  2. ParadoxV5 commented on Jun 4, 2023

    @ParadoxV5
    Contributor

    Can simply use Proc for lambdas; this new syntax mainly benefits untyped blocks

    untyped -> void

    This suggestion is uncomfortably similar to (untyped) -> void. In fact, it conflicts with the possibility of making arguments’ round parentheses optional (if there’s such a possibility).

  3. soutaro commented on Jun 6, 2023

    @soutaro
    MemberAuthor

    I'm going to implement it in (?) -> void syntax. ... would be confusing because Ruby has similar syntax with totally different semantics. untyped -> void is too similar to normal positional argument.

  4. modified the milestones: RBS 3.2, RBS 3.3 on Aug 17, 2023
  5. modified the milestones: RBS 3.3, RBS 3.4 on Nov 21, 2023
  6. modified the milestones: RBS 3.4, RBS 3.5 on Dec 14, 2023
  7. added
    ReleasedPRs already included in the released version
    on Jun 6, 2024
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

    ReleasedPRs already included in the released versionenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions