Showing TypeFunction style

Basile B. b2.temp at gmx.com
Sat Oct 3 14:16:09 UTC 2020


On Saturday, 3 October 2020 at 12:28:47 UTC, Basile B. wrote:
> On Saturday, 3 October 2020 at 10:47:47 UTC, Stefan Koch wrote:
>> On Saturday, 3 October 2020 at 10:05:23 UTC, Basile B. wrote:
>>> On Saturday, 3 October 2020 at 08:44:53 UTC, Stefan Koch 
>>> wrote:
>>>> On Saturday, 3 October 2020 at 07:36:17 UTC, Jacob Carlborg 
>>>> wrote:
>>>>> On 2020-10-03 00:24, Stefan Koch wrote:
>>>>>
>>>>>> // temporarly needed because parser issues ....
>>>>>> auto makeAliasArray(alias[] types ...)
>>>>>> {
>>>>>>      return types;
>>>>>> }
>>>>>
>>>>> Not sure if other cares, but your examples will look more 
>>>>> appealing if you fix the parser.
>>>>
>>>> Yeah ... I know. It's one of these things I keep putting off.
>>>>
>>>> You could remove all the aliases from my example if I did 
>>>> fix the parser.
>>>
>>> a DIP for TypeFunction requires the parser change. There are 
>>> two possibilities
>>>
>>> 1. a new keyword
>>> 2. use a symbol, e.g like template instanciation with a bang
>>>
>>> The first soltion is absolutly aweful. It leads to deprecate 
>>> an identifier, which will delay the feature.
>>>
>>> The second is more likely what should be adopted. At first 
>>> glance I'd propose a double bang.
>>>
>>>     string templateStuff = instance!stuff();
>>>     string typefuncstuff = callAtCompileTime!!stuff()
>>>
>>> so after the double bang, the parser can parse a 
>>> TypeFuntionCallExpr call instead of a CallExpr.
>>
>> Actually, no.
>> You can just have a rule which goes like this.
>> Function calls may accept types.
>> It doesn't change much, since just builtin types are rejected 
>> by the parser.
>> Anything else is an unresolved Identifier as far as the parser 
>> is concerned.
>
> 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.


More information about the Digitalmars-d mailing list