rbs icon indicating copy to clipboard operation
rbs copied to clipboard

Add in `&untyped`

Open sampersand opened this issue 1 year ago • 3 comments

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

sampersand avatar Nov 17 '23 01:11 sampersand

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

ParadoxV5 avatar Nov 18 '23 00:11 ParadoxV5

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

soutaro avatar Nov 20 '23 00:11 soutaro

def foo: (&block_type blk) -> void

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

ParadoxV5 avatar Nov 20 '23 20:11 ParadoxV5