Reimplementing the bulk of std.meta iteratively

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Sep 29 13:19:23 UTC 2020


On 9/29/20 8:55 AM, Steven Schveighoffer wrote:
> On 9/29/20 8:02 AM, Patrick Schluter wrote:
>> Your AA example is a good one. If it wasn't in the language, it would 
>> be the same issue with AA as in any other language that defines it in 
>> libraries: several different incompatible restricted implementations.
> 
> AA is not that far from being a library type.
> 
> If you discount the magic casting that AAs can do (which isn't all that 
> useful), there is one (yes ONE) feature that AAs do that a library type 
> cannot. And that is an implicit adding of an element in certain cases. 
> The reason AAs can do it is because the compiler calls a different 
> opIndex (it's not called opIndex, but some extern(C) hook) when it's in 
> this mode, but only for AAs.
> 
> In fact, AAs are mostly already a library type, thanks to a lot of 
> incremental effort over the years to lower the implementation to 
> templates. Except for this one thing.

Thanks, good to know. I now recall I helped a little with that. (Was it 
the length function? empty? some range-related addition?) This supports 
the original point - it took much effort over years to disentangle and 
undo all this magic.


More information about the Digitalmars-d mailing list