Swift Pointer Syntatic Sugar


(Alejandro Alonso) #22

If we're reading left to right the obvious answer is UnsafeMutablePointer<Int>?. Compared to Int?* being UnsafeMutablePointer<Int?>.

(Happy Human Pointer) #23

But wouldn't the ? be more important than the * because it is a system-defined thing? Then we end up will shorthands having precedencegroups.

(John McCall) #24

There's no way for "precedence" to cause the ? to bind before the * in that example; that would have to be its own complex grammar rule, like C's declarator syntax.

If we added user-customizable type sugar using the current operator parsing rules, that would actually be parsed as a single *? operator, which presumably wouldn't be declared and so would be ill-formed.

(Happy Human Pointer) #25

Oh. Sorry

(Davide De Franceschi) #26

The important thing here is that if such s system were in place then the system ones would be defined through this as well and wouldn’t be compiler special exceptions