digitalmars.D - Re: Automatic code refactoring
- Robert Fraser <fraserofthenight gmail.com> Aug 04 2007
- BCS <ao pathlink.com> Aug 05 2007
BCS Wrote:I'd go the other way I would like this is convert a class to abstract, derive a cocreate class from it that acts as the original class does, replace all 'new's and derivations with this new class. extract interface from several classes (only ask about overlapping functions) convert "auto T = ..." to it's actual type --- select methods from a class and build a mixin template for them with interface extraction this would allow extracting interface + functionality blocks interface I { int foo() } template I_impl() { int foo(){...} } ... class C : I { mixin I_impl!() }
All good ideas! They'll be there.generate a explicit specialization of a template from a general one template T(U) { U foo; } becomes, for int template T(U) { U foo; } template T(U : int) { int foo; }
I don't really understand what you mean here and why this would be useful. Can you elaborate, please?
Aug 04 2007
Reply to Robert,BCS Wrote:I'd go the other way I would like this is convert a class to abstract, derive a cocreate class from it that acts as the original class does, replace all 'new's and derivations with this new class. extract interface from several classes (only ask about overlapping functions) convert "auto T = ..." to it's actual type --- select methods from a class and build a mixin template for them with interface extraction this would allow extracting interface + functionality blocks interface I { int foo() } template I_impl() { int foo(){...} } ... class C : I { mixin I_impl!() }
generate a explicit specialization of a template from a general one template T(U) { U foo; } becomes, for int template T(U) { U foo; } template T(U : int) { int foo; }
useful. Can you elaborate, please?
This would be for where you want to have a special case of a template for some given inputs. It assumes that the general case is good starting point. The most basic form would do a copy/paste of a template and insert "__ : type/value" code into the args list. A better version would then run whatever parts of the template logic it could and drop failed static ifs and maybe some type deductions.
Aug 05 2007