Templates, D way

crimaniak via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 5 07:01:02 PDT 2017


On Tuesday, 5 September 2017 at 12:54:20 UTC, Void-995 wrote:
> Thanks, that definitely working and doesn't require mixin with 
> strings. But while waiting for response I've tried another 
> thing, and I doubt I would able do to that without string now:
>...
> 		int %sCount;
> 		int %sOffset;

Yes, you can make such custom names only with string mixin, as I 
know. Computermatronic gives a good example how to do it simple 
way. I can give two additional advises: as I understand offsets 
as sizes are fixed so think about using unions to access sub 
structures instead of these auto-generated methods; I have a long 
history of using tricks like this starting from CHAIN MERGE usage 
in GW-BASIC to add some functions and for now such things are 
definitely code smell for me. There is always a way to do the 
same, but better.



More information about the Digitalmars-d mailing list