Yeah, you're right (case (1) also works with a template ctor as well - in C++ this would allow for implicit conversions as well, that's why I thought about using it this way). As I said, I had already abandoned this approach and decided on using .mangleof sorting anyway for elegance. I think my proposal write-up is almost ready, will submit it today or tomorrow.
(Cristi Cobzarenco) Pofile: http://www.google.com/profiles/cristi.cobzarenco On 30 March 2011 15:26, David Nadlinger <[email protected]> wrote: > On 3/30/11 11:21 AM, Cristi Cobzarenco wrote: > >> Seems right to me, am I missing something? >> > > opAssign isn't taken into consideration when initializing variables or > passing values to functions. An example probably says more than thousand > words: > > --- > struct Test { > ref Test opAssign(int i) { > value = i; > return this; > } > int value; > } > > void foo(Test t) {} > > void main() { > // Neither of the following two lines compiles, IIRC: > Test t = 4; // (1) > foo(4); // (2) > } > --- > > You can make case (1) work by defining a static opCall taking an int, which > will be called due to property syntax, but I can't think of any solution for > (2). > > David >
