On Tuesday, 2 July 2013 at 07:35:39 UTC, monarch_dodra wrote:
One of the "big" problems with allowing UFCS and constructors
is that a "." which meant "scope" can now mean "function call".
Just for the interest - try to guess what following in D may be:
a.b = c.d();
This is a good example how overloaded D syntax is.
--------
(1) is a standard scope call: instantiate a Bar.S. This prints
"S(0)".
(2) is actually: "get the value j from Bar, and then UFCS
construct an S using that J". This prints: "S([1, 1, 1, 1, 1,
1, 1, 1, 1, 1])"
Furthermore, I find UFCS construction confusing on the grounds
that there is no actual "constructor function" eg: "this(...)"
call: This is just aggregate initialization, which looks *very*
confusing when written that way.
------------------------------------
So to sum up the question: Was UFCS + constructors are really
desired feature? Was it taken into account? Do we want to keep
it?
I think this worth bug issue. Even if this behavior would be
proven to be correct (I guess many wish it wouldn't), bugzilla
request could be posted as an ask to provide use case in D
documentation site to show this behavior explicitly.