Showing TypeFunction style

Timon Gehr timon.gehr at gmx.ch
Sun Oct 4 05:14:02 UTC 2020


On 04.10.20 07:04, Basile B. wrote:
> On Saturday, 3 October 2020 at 21:36:20 UTC, Stefan Koch wrote:
>> On Saturday, 3 October 2020 at 14:16:09 UTC, Basile B. wrote:
>>> On Saturday, 3 October 2020 at 12:28:47 UTC, Basile B. wrote:
>>>>
>>>> calls to type functions have to accept basic types, i.e keywords.
>>>> Even if you've made the biggest part of semantic, you still need to 
>>>> specify this.
>>>
>>> not to have a special syntax will make the compiler slower. The 
>>> expression semantic for a call is already complex, it's better to 
>>> have a dedicated call with a dedicated syntax for type functions.
>>
>> type functions are supposed to support UFCS.
>> How would I do that with the calling syntax you propose?
> 
> UFCS style still works:
> 
>    size_t SizeOf(alias T){ return T.sizeof; }
> 
>    static assert (SizeOf!!(ubyte) == 1);
>    static assert (ubyte!!SizeOf() == 1);
>    static assert (ubyte!!SizeOf == 1);
> 
> although you clearly loose the feel that it's like a builtin property.

IMO this is ugly and unnecessary. The distinction between types and 
expressions in the parser is pointless anyway.


More information about the Digitalmars-d mailing list