[Pitch] Type Wrappers

The thing that worries me is that some of the examples are starting to look like protocols where it defines a suite of behavior/capabilities applied to arbitrary types

@dynamicMemberLookup is an attribute to have the compiler support syntax sugar for accessing properties through a well-defined subscript, leaving much of the actual implementation up to the type to define, but this new wrapper is actually "hey, go generate a ton of properties and storage, but don't expose all these details unless someone knows to go looking for them or recognizes the synthesized nature of the generated code".

In the proposal there was mentioned that "this is boilerplate that would have to be duplicated for every object" and traditionally that type of space is solved with metaprogramming through either a template or macro system.

The fact that it's not composable, and in several cases hiding details about how the type works (side-effects), I'm very concerned we'd be introducing footguns that are going to have to be avoided primarily through documentation or strong API design by the implementers.

10 Likes