# Operator member syntax

**URL:** <https://forums.swift.org/t/operator-member-syntax/31773>\
**Category:** Discussion\
**Created:** [December 17, 2019, 7:15pm UTC](https://forums.swift.org/t/operator-member-syntax/31773 "2019-12-17T19:15:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dan-zheng](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dan-zheng/32/2534_2.png) [@dan-zheng](https://forums.swift.org/u/dan-zheng)\
**Post date:** [December 17, 2019, 7:18pm UTC](https://forums.swift.org/t/operator-member-syntax/31773/2 "2019-12-17T19:18:40Z")

</div>

Context: operator member syntax popped up in [a discussion](https://github.com/apple/swift/pull/27545/files#r358622964) regarding the `@derivative(of:)` and `@transpose(of:)` attributes for [differentiable programming](https://forums.swift.org/t/differentiable-programming-mega-proposal/28547).

These attributes reference a declaration, which may be an operator:

```swift
@derivative(of: Float.+)
func addDerivative(lhs: Float, rhs: Float) -> (value: Float, differential: (Float, Float) -> Float) { … }

```

In practice, qualified operator member syntax isn't necessary for these attributes. Type-checking for `@derivative(of:)` and `@transpose(of:)` currently require the operator to be defined in the same type context, where lookup is not ambiguous:

```swift
extension Float {
    @derivative(of: +(_:_:))
    static func addDerivative(lhs: Float, rhs: Float) -> (value: Float, differential: (Float, Float) -> Float) {
        (lhs + rhs, { $0 + $1 })
    }
}

```

But this motivated the discussion nonetheless!

---

_[View the full topic](https://forums.swift.org/t/operator-member-syntax/31773)._
