digitalmars.D.announce - Please test: black holes and white holes
- Shin Fujishiro (13/13) May 18 2009 I've implemented two templates: defineBlackHole and defineWhiteHole.
- Andrei Alexandrescu (3/19) May 19 2009 Great work, Shin! I'll look into it.
- Andrei Alexandrescu (11/27) May 19 2009 The code looks very clean and well-written. Great job.
- Shin Fujishiro (11/25) May 19 2009 At first I wrote BlackHole as a template class. But I was biten by this:
- Shin Fujishiro (4/9) May 19 2009 Also, there's a trick to extracting parameter storage classes from a
- Andrei Alexandrescu (3/15) May 19 2009 Perfect!
I've implemented two templates: defineBlackHole and defineWhiteHole. Given a class or interface C, they generate a declaration of a new class which automatically implements all abstract methods defined in C and its ancestors. They seems to be working fine (dmd 2.030). Could you please test them? And should they be added to Phobos? These patches have to be applied to Phobos: http://d.puremagic.com/issues/show_bug.cgi?id=2989 http://d.puremagic.com/issues/show_bug.cgi?id=2996 Code: http://code.google.com/p/kabe/source/browse/branches/bhwh/test.d http://code.google.com/p/kabe/source/browse/branches/bhwh/nonstd/traits.d http://code.google.com/p/kabe/source/browse/branches/bhwh/nonstd/typecons.d
May 18 2009
Shin Fujishiro wrote:I've implemented two templates: defineBlackHole and defineWhiteHole. Given a class or interface C, they generate a declaration of a new class which automatically implements all abstract methods defined in C and its ancestors. They seems to be working fine (dmd 2.030). Could you please test them? And should they be added to Phobos? These patches have to be applied to Phobos: http://d.puremagic.com/issues/show_bug.cgi?id=2989 http://d.puremagic.com/issues/show_bug.cgi?id=2996 Code: http://code.google.com/p/kabe/source/browse/branches/bhwh/test.d http://code.google.com/p/kabe/source/browse/branches/bhwh/nonstd/traits.d http://code.google.com/p/kabe/source/browse/branches/bhwh/nonstd/typecons.dGreat work, Shin! I'll look into it. Andrei
May 19 2009
Shin Fujishiro wrote:I've implemented two templates: defineBlackHole and defineWhiteHole. Given a class or interface C, they generate a declaration of a new class which automatically implements all abstract methods defined in C and its ancestors. They seems to be working fine (dmd 2.030). Could you please test them? And should they be added to Phobos? These patches have to be applied to Phobos: http://d.puremagic.com/issues/show_bug.cgi?id=2989 http://d.puremagic.com/issues/show_bug.cgi?id=2996 Code: http://code.google.com/p/kabe/source/browse/branches/bhwh/test.d http://code.google.com/p/kabe/source/browse/branches/bhwh/nonstd/traits.d http://code.google.com/p/kabe/source/browse/branches/bhwh/nonstd/typecons.dThe code looks very clean and well-written. Great job. One question - has anything prevented you from writing a shell class? class BlackHole(C) { mixin(generateBlackHoleCode(C.stringof)); } ? It's a tad more comfortable to just say BlackHole!C instead of generating it separately. Andrei
May 19 2009
Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:The code looks very clean and well-written. Great job. One question - has anything prevented you from writing a shell class? class BlackHole(C) { mixin(generateBlackHoleCode(C.stringof)); } ? It's a tad more comfortable to just say BlackHole!C instead of generating it separately.At first I wrote BlackHole as a template class. But I was biten by this: -------------------- module test interface X {} interface C { X foo(); } -------------------- BlackHole!C could not tell what the X is because BlackHole and X are defined in different modules. -> "Error: identifier 'X' is not defined" Now it came to my mind that the problem could be solved by inserting "alias ReturnType!(C.foo) X;" in generated code. I'll try this.
May 19 2009
I wrote:Now it came to my mind that the problem could be solved by inserting "alias ReturnType!(C.foo) X;" in generated code. I'll try this.OK, I did it! I checked in a new version.http://code.google.com/p/kabe/source/browse/branches/bhwh/test.d http://code.google.com/p/kabe/source/browse/branches/bhwh/nonstd/traits.d http://code.google.com/p/kabe/source/browse/branches/bhwh/nonstd/typecons.dAlso, there's a trick to extracting parameter storage classes from a parameter type tuple (template parameterStorageClasses in traits.d).
May 19 2009
Shin Fujishiro wrote:I wrote:Perfect! AndreiNow it came to my mind that the problem could be solved by inserting "alias ReturnType!(C.foo) X;" in generated code. I'll try this.OK, I did it! I checked in a new version.http://code.google.com/p/kabe/source/browse/branches/bhwh/test.d http://code.google.com/p/kabe/source/browse/branches/bhwh/nonstd/traits.d http://code.google.com/p/kabe/source/browse/branches/bhwh/nonstd/typecons.dAlso, there's a trick to extracting parameter storage classes from a parameter type tuple (template parameterStorageClasses in traits.d).
May 19 2009