Discussion Thread: DIP 1037--Add Unary Operator ...--Community Review Round 1

Andrei Alexandrescu SeeWebsiteForEmail at erdani.com
Fri Oct 30 18:29:47 UTC 2020


On 10/29/20 9:48 AM, Steven Schveighoffer wrote:
>  From the Feedback Thread:
> 
>> * Major bug: the "Rationale" discusses only expression, whereas
>> staticMap does not use expressions. It just processes tuples, which may
>> contain types. Types cannot appear in expressions. C++ goes to great
>> lengths to distinguish between template parameter packs (which may be
>> one of type parameter pack, value parameter pack, and template template
>> parameter pack) and function parameter packs (which may only be
>> parameter declarations). By the Rationale nothing except expressions
>> will be accessible to D's proposed "...". That means no staticMap for
>> non-valies (e.g. staticMap!(Unqual, types)), which probably wasn't the
>> intent of the DIP.
> 
> I am confused by this. Isn't it fine to work with expressions only?
> 
> I mean staticMap's implementation can be replaced with a ... expansion, 
> because even though there might be types in the list, there are no types 
> in staticMap, just tuples.

I don't think it works that way, no.

> And a type can appear in an expression, as a template parameter:
> 
> alias everyOther = AliasSeq!(0, 2, 4);
> 
> alias everyOtherType = (AliasSeq!(int, uint, char, byte, ubyte, 
> int)[everyOther])...;
> 
> I think the DIP is intending for staticMap to be wholesale replaced with 
> this, and seems to be saying this to me. I don't understand the above 
> complaint, and why static map wouldn't work with types.

What would the implementation of staticMap with the DIP look like? As 
far as I can tell from the DIP it cannot be done.

> Perhaps it's simply vocabulary that is the problem?

May as well. The way the DIP is written, there's no discussion of tuples 
containing anything else but values.



More information about the Digitalmars-d mailing list