Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in &untyped #1622

Open
sampersand opened this issue Nov 17, 2023 · 3 comments
Open

Add in &untyped #1622

sampersand opened this issue Nov 17, 2023 · 3 comments
Assignees
Milestone

Comments

@sampersand
Copy link
Contributor

Currently, *untyped and **untyped can be used to accept any amount of any type of positional and keyword arguments. However, there's no way to accept a block of any type:

def foo: () { (*untyped, **untyped) -> untyped } -> void

indicates that the block doesn't accept block parameters itself. To fix this, you need to do

def foo: () { (*untyped, **untyped) { (*untyped, **untyped) -> untyped } -> untyped } -> untyped

But that block also needs a block itself, etc. ad nauseum. So, my proposal is to add in &untyped syntax, eg def foo: (&untyped) -> void. (This syntax also allows the possibility of naming the blocks—&untyped foo, and might allow for naming block variables themselves, such as: def yield_ten: (&block) { (Integer) -> void } -> void

@ParadoxV5
Copy link
Contributor

Add a ? prefix to indicate optional block

def foo: () ?{ (*untyped, **untyped) -> void } -> void

Possible alternative:

def foo: () ?{ (...) -> void } -> void

Where ... eats everything just like in

def example(...) = 42 # The entire `...` is unused

@soutaro soutaro self-assigned this Nov 20, 2023
@soutaro
Copy link
Member

soutaro commented Nov 20, 2023

The proposal makes sense. Will compose a proposal for block syntax updates including this.

@soutaro soutaro added this to the RBS 3.4 milestone Nov 20, 2023
@ParadoxV5
Copy link
Contributor

def foo: (&block_type blk) -> void

The block_type must be a _ToProc (Hah! #1223).

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

No branches or pull requests

3 participants