Introduction to programming with compile time sequences in D

data pulverizer data.pulverizer at gmail.com
Tue Aug 25 16:13:23 UTC 2020


On Tuesday, 25 August 2020 at 16:10:21 UTC, data pulverizer wrote:
> On Tuesday, 25 August 2020 at 16:01:25 UTC, data pulverizer 
> wrote:
>> On Tuesday, 25 August 2020 at 14:02:33 UTC, Petar Kirov 
>> [ZombineDev] wrote:
>>> ...
>>> You can find a full example of this here:
>>> https://run.dlang.io/gist/run-dlang/80e120e989a6b0f72fd7244b17021e2f
>>>
>> There is an issue with `AliasTuple` though, you can't directly 
>> print its collections with pragma:
>>
>> ```d
>> alias coll = AliasSeq!(s1, s2, s3, s7);
>> pragma(msg, coll);
>> ```
>>
>> I get the following error:
>>
>> ```d
>> onlineapp.d(29): Error: cannot interpret AliasTuple!1 at 
>> compile time
>> onlineapp.d(29): Error: cannot interpret AliasTuple!(1, 2) at 
>> compile time
>> ...
>> tuple((__error), (__error), (__error), (__error))
>> ```
>
> p.s. I did include a `Tuple` - like implementation in my 
> article at the later sections, but it was based on a template 
> struct.

Fixed it, using this now works:

```d
template AliasTuple(seq...)
{
   struct AliasTuple
   {
     alias expand = seq;
     enum length = seq.length;
   }
}
```


More information about the Digitalmars-d-announce mailing list