Extended Type Design.

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri Mar 16 17:12:57 PDT 2007


Bill Baxter wrote:
> This:
>   const int[int**][]*[char[]][3][17][3,17]* x;
> 
> is *already* unreadable (plus I don't think that [3,17] part is legal 
> D).

---
$ cat test.d
import std.stdio;

void main() {
         int[3,17] x;
         writefln(typeid(typeof(x)));
}
$ dmd -run test.d
int[17]
---

http://www.digitalmars.com/d/expression.html#Expressions
---
The left operand of the , is evaluated, then the right operand is 
evaluated. The type of the expression is the type of the right operand, 
and the result is the result of the right operand.
---

This is mostly for C and C++ compatibility, AFAICT. There, it's 
typically used in macros that need it to perform multiple actions that 
can only be done in separate expressions, without having the macros 
expand to full statements.
But it's also used in one of the multiply-evaluated clauses of a loop 
statement (for example, it can be used to increment multiple counters of 
a for loop on each iteration).
It's also horribly abused as an overloaded operator in (amongst others) 
boost::lambda, where it replaces ';' for lambda expressions...



More information about the Digitalmars-d mailing list