Improving the UI of generics

Yes, for simple cases shorthands are fine, a return keyword might be fine for it.

But in addition to shorthands consider those people who are not so intimately familiar with these relatively advanced concepts and syntax.

People have learned generics, it has named types, it’s maybe more similar to several other languages, and people have learned to use conformances, joined conformances and where clauses with it.

Now they try to use existentials, they are bit similar, except they don’t have names (really), and people mistake the Protocol for its name. But the where clauses are same, so some parts are familiar.

then we have some. Sure simple cases are fine. But if you go into situations similar to where clauses you’re confused again, just like with existentials.

The more I think of this It feels like fundamental flaw in swift syntax design (especially in protocols), and all the more important that both existentials any and reverse generics some should have named type syntax for ease of use, as well as, for handling complexity reasons. This is irrespective of whether there is a shorthand syntax for them.

EDIT:
And by named type syntax I refer to the one mentioned before:
any Protocol A
some Protocol S

1 Like