SE-0253: Static callables

Well what I'm thinking is that we have a couple of closely-related features, and tantalising gaps:

kind of like an operator ():

  • dynamic callable
  • static callable

kind of like an operator .:

  • dynamic member lookup
  • static member lookup? A forwarding mechanism like C++'s operator -> perhaps? (which, FWIW, also behaves a bit differently to other operators).

Of course they are kind of magic operators, because they are built-in to the language and can support multiple signatures and so on. Then again, the other solutions like a new decl type are also kind of magic features that don't generalise to other things in the language.

This is digressing a bit, but looking at the proposal for @dynamicMemberLookup, I see that marker-protocols and methods are listed under "alternatives considered", but I don't remember if we also considered operators.

Anyway that's kind of the extent of my thoughts on the subject, as something for the core team to consider. I would very much like the functionality, however it is spelled, and I think that implicit conversion to function types is important. I don't think we need a callable protocol - callable is already implied by being written as a function type, and we already do closure specialisation which one would hope could be generalised to handle any callable object.

2 Likes