Bug 8965 – Implement mixin template for forwading constructors

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-05T20:50:00Z
Last change time
2012-12-31T09:57:24Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-11-05T20:50:40Z
The syntax should be a simple as doing 'mixin Forward' in a class. This would alleviate the pain of having to duplicate code just to forward to base class constructors. Hardcoded example: import std.stdio; mixin template Forward() { this(int x) { super(x); } } class Foo { this(int i) { writeln(i); } } class Bar : Foo { mixin Forward; } void main() { auto bar = new Bar(1); } It should be relatively easy to implement.
Comment #1 by peter.alexander.au — 2012-12-31T09:57:24Z
Duplicates your more recent enhancement request. Marking this one as dup because the more recent one has a possible implementation. *** This issue has been marked as a duplicate of issue 9066 ***