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:
- Tagged union interfaces
- Comptime Interfaces using a switch on implementations
- Runtime interfaces with a Vtable
- Runtime interfaces with anyopaque and @ptrCast(@alignCast(p))
- 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.