grauzone wrote: > Steven Schveighoffer wrote: >> option 2, return a special struct which uses properties to set the >> values in the original widget. > > Now this would generate a mess (lots of bloat). Now I'm not sure; maybe > macros could provide a way out (auto generate the code bloat), or > possibly you could use alias this to properly "wrap" a value? Any ideas > on this? >
Just say no. It is far easier to optimize the nesting assignments. It is also easy to optimize the nesting assignments by hand if it's really necessary. Not to mention if you don't optimize the nesting assignments at all, they are still orders of magnitude faster than this sort of thing, and only slightly slower than optimal code. What worries me more about this is things like type casting and the unary ++ the special struct may be expected to overload. This is the case in something like "array.length++;". length would return a proxy struct that would have to: 1) be implicity castable to size_t 2) overload opPostInc, opPostDec, opXxxAssign, and opAssign. That's a lot of DRY violation and tedium. You have to do it for every property that sets a calculated value.
