DIP1001: DoExpression

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 6 10:01:28 PDT 2016

On 06.09.2016 17:23, Steven Schveighoffer wrote:
> On 9/6/16 10:17 AM, Timon Gehr wrote:
>> On 06.09.2016 16:12, Steven Schveighoffer wrote:
>>> I'm not sure I agree with the general principal of the DIP though. I've
>>> never liked comma expressions, and this seems like a waste of syntax.
>>> Won't tuples suffice here when they take over the syntax? e.g. (x, y,
>>> z)[$-1]
>> (Does not work if x, y or z is of type 'void'.)
> Let's first stipulate that z cannot be void here, as the context is you
> want to evaluate to the result of some expression.
> But why wouldn't a tuple of type (void, void, T) be valid?

Because 'void' is special. (Language design error imported from C.)

struct S{
     void x; // does not work.

There can be no field (or variables) of type 'void'. (void,void,T) has 
two fields of type 'void'.

Just fixing the limitations is also not really possible, as e.g. void* 
and void[] exploit that 'void' is special and have a non-compositional 

> It could also auto-reduce to just (T).
> -Steve

That would fix the limitation, but it is also quite surprising behaviour.

More information about the Digitalmars-d mailing list