Append to 'map' result

Jean-Louis Leroy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 5 04:31:20 PDT 2017


On Wednesday, 5 July 2017 at 01:43:46 UTC, Ali Çehreli wrote:
> On 07/04/2017 05:52 PM, Jean-Louis Leroy wrote:
>> On Wednesday, 5 July 2017 at 00:28:01 UTC, Ali Çehreli wrote:
>>> On 07/04/2017 04:57 PM, Jean-Louis Leroy wrote:
>>>> [...]
>>> No time to dig deeper but this is because the two ranges that 
>>> chain()
>>> receives do not have a common type. (Rather, that type is 
>>> 'void'):
>>>
>>> [...]
>>
>
> This is related to TypeInfo.init, which unfortunately is *not* 
> the .init property in this case. :( Luckily, it will be fixed 
> in 2.075. This is what object.d has:
> [...]
> So, unfortunately, most Phobos range functions cannot be used 
> with TypeInfo as they would invariably touch ElementType. Here 
> is a halfway workaround that uses each() instead of map(): :/

Aaah, so I was not doing anything wrong ;-)

I was trying to factor this code:

       foreach (i; k.interfaces) {
         if (i.classinfo in classMap) {
           v.bases ~= classMap[i.classinfo];
         }
       }
       if (k.base in classMap) {
         v.bases ~= classMap[k.base];
       }

i.e. process the class base along with the interfaces in the same 
loop. I dwelled on it because my goal with this project is to 
learn (and evaluate) D.

Anyway, I am building my own graph of enriched ClassInfo objects; 
once that is done, I won't be impacted with the bug anymore.

Thanks for the diagnostic...

J-L




More information about the Digitalmars-d-learn mailing list