Precedence/associativity of member access and function call

Do the . member access and () function call syntactical elements have defined precedence and associativity that's written down in a doc somewhere? They are not in the official list of operators linked from the language reference. (Whereas the assignment operator is.)

These are not operators but rather part of the language grammar. There’s a lot of complexity here but a good place to start would be the explicit-member-expression and function-call-argument-clause productions in The Swift Programming Language > Summary of the Grammar.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

2 Likes

Yup, understood they're not formally operators. I guess I can parse (ahem) the information I need out of the grammar. Thank you for the pointer!

FWIW, I'm pretty sure they both binds tighter than all operators (including prefix & postfix). So this:

var a = [1, 2, 3]
a . randomElement()!

would look like this:

((a.randomElement())!)

Thanks. That is what I would expect (and believe I have observed) as well.