www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Please test: black holes and white holes

reply Shin Fujishiro <rsinfu gmail.com> writes:
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
next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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.d
Great work, Shin! I'll look into it. Andrei
May 19 2009
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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.d
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. Andrei
May 19 2009
parent reply Shin Fujishiro <rsinfu gmail.com> writes:
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
parent reply Shin Fujishiro <rsinfu gmail.com> writes:
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.d
Also, there's a trick to extracting parameter storage classes from a parameter type tuple (template parameterStorageClasses in traits.d).
May 19 2009
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Shin Fujishiro wrote:
 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.d
Also, there's a trick to extracting parameter storage classes from a parameter type tuple (template parameterStorageClasses in traits.d).
Perfect! Andrei
May 19 2009