Bug 3673 – inheritance + if clause = no go

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-01-04T11:34:00Z
Last change time
2013-03-10T20:29:26Z
Keywords
pull, rejects-valid
Assigned to
andrej.mitrovich
Creator
andrei

Comments

Comment #0 by andrei — 2010-01-04T11:34:00Z
This code should compile: interface OutputRange(T...) if (T.length == 1) { void put(T[0] value); } interface OutputRange(T...) : OutputRange!(T[0]), OutputRange!(T[1 .. $]) if (T.length > 1) { } The first error is "members expected" upon the "if" clause in the second definition, which suggests that the syntax is not yet supported.
Comment #1 by samukha — 2010-01-05T03:00:42Z
This syntax is supported: interface OutputRange(T...) if (T.length > 1) : OutputRange!(T[0]), OutputRange!(T[1 .. $]) { }
Comment #2 by samukha — 2010-01-05T04:22:26Z
Also, each interface adds sizeof(void*) bytes to the class instance size. While recursive inheritance provides a separate interface for each type, which may be a nice property, the overhead, for example, of OutputRange!basicTypes would be significant.
Comment #3 by andrei — 2010-01-05T06:04:40Z
Thanks, Max. Yah, the overhead is kinda crippling. I'm also thinking of TextOutputRange, which is an alias for OutputRange!(const(char)[], const(wchar)[], const(dchar)[], char, wchar, dchar). That would be 24 bytes to boot. Maybe I better use a recursive mixin to generate all functions inside the interface.
Comment #4 by Kosmonaut — 2010-08-20T20:55:45Z
*** Issue 4698 has been marked as a duplicate of this issue. ***
Comment #5 by yebblies — 2012-10-27T09:27:12Z
Comment #6 by github-bugzilla — 2013-03-10T20:00:51Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b8ed73f4ffc49272f95c6ce9ceb56330e3a101b9 Fixes Issue 3673 - Allow putting constraint after inheritance list. https://github.com/D-Programming-Language/dmd/commit/43251183f885d5a309171b7139d94d22a60cace3 Merge pull request #1227 from AndrejMitrovic/Fix3673 [enh] Issue 3673 - Allow putting constraint after inheritance list