Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • 7
    I'm not sure why moving the type declaration after would affect this. Is x, y *int; two *int or one *int and one int? Making int* or *int one token instead of two would solve it, or using an additional syntactic element like the :, which could work in either direction. Commented Apr 19, 2016 at 18:56
  • 1
    Indeed, I cannot think of a real counter example that has the type second and no separator. But there are still two distinct changes there. One could have int*: x, y and the ambiguity is gone while still having the type first. It's not having the type after that avoids the problem, it's the addition of the separator. Commented Apr 19, 2016 at 19:29
  • 3
    Go has x, y int without separator. Commented Apr 20, 2016 at 12:23
  • 2
    And in Go, x, y *int means "declare two variables, x and y, with the type pointer-to-int". Commented Apr 20, 2016 at 15:21
  • 14
    C# uses the prefix syntax, yet it treats int[] x, y as two arrays. It's just the silly C syntax which treats those modifiers as unary operators on the variable (and a mix of prefix and postfix, no less) that causes problems. Commented Apr 23, 2016 at 14:01