Templates, D way

Void-995 via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 5 07:55:21 PDT 2017


On Tuesday, 5 September 2017 at 14:01:02 UTC, crimaniak wrote:
> 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.

Using unions? <Type>Count and <Type>Offset are different 
depending on input data, so the address where they are is varying 
depending on which file I've loaded. Or I didn't get what you 
meant.


More information about the Digitalmars-d mailing list