On 07/03/13 05:21, Jonathan M Davis wrote: > On Wednesday, July 03, 2013 04:54:41 Timon Gehr wrote: >> There is nothing to be gained from subtly breaking this analogy. UFCS >> can be applied to any callable. >> >> You are probably not going to like this, but the following code also works: >> >> import std.stdio; >> >> struct S{ >> int opCall(int x){ return x+1; } >> } >> >> S s; >> >> void main(){ >> auto x = 1; >> writeln(x.s); >> } > > That is _very_ broken IMHO. It makes no sense for parens to be optional with > opCall. The whole point of opCall is to overload the parens!
This is an optional-parens issue, not an UFCS issue. Ie Timon's example only works w/o property enforcement, what actually happens is "writeln(x.s())". A really bad idea - yes, but it's not an UFCS and ctor specific problem. artur