What's @_transparent for?

Also, is there a list of attributes used in the standard library, much like the one in The Swift Programming Language book?

@_transparent is an underscored (stdlib-private) attribute. You shouldn’t use it in your own libraries or applications (given the sub-forum, you probably know this - just making it clear for anyone else).

But FWIW, it is documented: swift/TransparentAttr.md at main · apple/swift · GitHub

Other attributes are documented in the standard library programmer’s manual (but not all of them - for instance, it doesn’t appear that @_alwaysEmitInToClient is documented there): swift/StandardLibraryProgrammersManual.md at main · apple/swift · GitHub

2 Likes

@_transparent is an extremely strong form of @inlinable that ensures the call’s stack frame isn’t even preserved in the debug info. For example, if you try to set a breakpoint in Int.+(_:_:), you’ll probably never see it hit in your program; this is because the operator is marked @_transparent.

Like all underscored attributes, @_transparent is not intended for ordinary language users and its meaning could change if we happen to need something different from it.

9 Likes