Restricted function type based interface pattern

I just had a lot of fun reading through the discussion on issue #23367 which features a builtin (posssibly @Restricted()) to aid in optimization for interface types such as writer. I am curious as to:

  • How this would look in everyday code
  • How widespread this change would be to the stdlib and the idioms of the language and
  • What kinds of performance advantages this would bring to the compiler / what optimizations we would miss by not using it.
    As far as I’m aware, the interface patterns we have available so far are:
  1. Tagged union interfaces
  2. Comptime Interfaces using a switch on implementations
  3. Runtime interfaces with a Vtable
  4. Runtime interfaces with anyopaque and @ptrCast(@alignCast(p))
  5. Runtime interfaces with @fieldParentPtr

At a glance, I would think most runtime interfaces would be able to apply this @Restricted builtin and tagged union based interfaces would not, but im not sure on how comptime interfaces would change with this pattern.