First life-signs of type functions
Stefan Koch
uplink.coder at googlemail.com
Tue May 19 14:42:25 UTC 2020
On Wednesday, 6 May 2020 at 12:01:11 UTC, Stefan Koch wrote:
> On Wednesday, 6 May 2020 at 11:58:36 UTC, Stefan Koch wrote:
>> Now works on the Talias branch
>>
>
> https://github.com/dlang/dmd/compare/master...UplinkCoder:talias?expand=1
>
> As you can see the modifications aren't even that heavy.
> I am confident this will take significantly less time than
> re-implementing CTFE.
> Because it's a new feature and bugs can be fixed as they are
> discovered.
I've switched my development process, to targeting stable and
keeping the new branch green all the time.
That way super-delays like what happend with newCTFE should be
avoided.
On the new branch the following example will compile
```
auto getUDAs(alias T)
{
return __traits(getAttributes, T);
pragma(msg, typeof(return));
}
// we can't parse alias[];
alias alias_array = typeof(getUDAs(SerializeTag));
struct SerializeTag {}
struct TypeWithTags
{
alias type;
alias_array tags;
}
TypeWithTags typeWithTags(alias T)
{
auto udas = __traits(getAttributes, T);
return TypeWithTags(T, udas);
}
@SerializeTag struct ThisIsAType {}
alias x = ThisIsAType;
pragma(msg, typeWithTags(x));
// output TypeWithTags((ThisIsAType), [(SerializeTag)])
```
The branch is here (and should be green most of the time):
Note that you'll have to comment out the call to
`preFunctionParameters`
in expressionsem.d : 4176.
That is not done by default because it breaks the tests which
make sure that functions are not called with types.
(which is obivously what type functions want to do ;) )
More information about the Digitalmars-d
mailing list