Is SwiftUI part of the Swift language or not?

That’s my understanding as well. Generalizing the pattern of allowing user-defined "attributes" starting with @ has been discussed under the term "custom attributes" on the forum. As far as I know it hasn't been formalized yet, but here's a post from @Douglas_Gregor that summarizes the intent:

Using types for attributes, and their initializers to build values, means that we can build on existing infrastructure for (e.g.) runtime inspection (use as? dynamic casting), any future static-reflection facilities (which of course have to work with user-defined types and values thereof), and simplifies the problem space.

I don't think that we should allow just any type to be used as an attribute, though: we should require that types be marked with a (built-in!) attribute to indicate that the types themselves can be used as custom attributes.

I'd suggest that we reserve all attribute names starting with a lowercase letter or an underscore for the compiler; that fits well with Swift's API design guidelines suggesting that type names start with an uppercase letter.

2 Likes