Pitch: Introduce (static) callables

Thanks for the update and for working on this proposal! I assume protocols are allowed to have call requirements but that It isn’t 100% clear. Can you clarify that here as well as in the proposal?

Yes, protocols can declare call member requirements:

Ahh, I missed that when reading. Thanks for pointing it out!

1 Like

I like having this syntactic sugar, e.g. invoke in Kotlin, for working around other limitations.

But what I'd like more is a solution that integrates with the type system! That is, objects of type Callable (to use the name from the proposal; defined as protocol?) are functions; Adder should be of type Int -> Int. I would want to write [1,2,3].map(Adder(base: 3)) and have the compiler know what's going on.

Apparently, as per @Chris_Lattner3, that kind of integration is a ways off yet. I'd wait for that and not introduce limited-power sugar now. If it's to look like a function it better smell like one, too.