Description
Since as @alexcrichton pointed out this is a different bug from #10200, I'll file this one, though I think that issue is a good illustration of why tuple structs can't "just" be functions.
I think this would resolve a bunch of issues, especially if we use a different syntax (namely: Foo {x,y}
instead of Foo (x,y)
). Then nobody, including the reader of the program and the compiler, would think Foo
was an ordinary function, though we usually get away with this because the convention is to not give functions uppercase names. Based on what I've seen and heard the fact that tuple structs are functions is minimally used right now, so the weak version of this (not changing the syntax, but just making tuple structs not functions) would probably not break a whole lot of code, and every such instance can be easily converted to a closure.
Pedagogically, it is strange to have an item that creates both a type and a value (which is what struct Foo(x, y)
is doing--it creates a new type Foo
, and also a new value Foo
of type (x, y) -> Foo
). And as @cmr pointed out, when we create a regular struct we can't call it like a function--why can we do the same with tuple structs?